Connection Strings for All Databases

Introduction

Databases are widely used in applications to keep records. A large variety of Database Management Systems are available in the market and in use. Every DBMS needs a different format of the connection string. It's not possible to remember all those formats, so knowing how to get a Connection String for any database makes life easy.

UDL file Method

UDL Files are an easy way to get the desired connection string by simply filling in property pages. The following steps show how to make and use a UDL file for that.

1. Make a New Text Document

NewDoc

2. Open the Text Document, Click on Save As

SaveAs

3. Write the filename as something.udl, file type All files, click Save.

4. Now run something.udl

5. Click on the Provider tab. Select the provider and click Next.

Dllproperties

6. Give the DataBase Path

AccessDb2

accessDb23

7. Write Username, Password if any

properties

7. Click on Test Connection

testDiag

8. If it's OK, then close it now

9. Now open udl file as Text File with Notepad

openwith

11. The Last line will have the Connection String

ConnString

Visual Studio DataSource Method

1. Add DatagridView to your Form

2. Click on Arrow in the Top Right Corner of DataGridView, Click Choose DataSource, Select Add New DataSource

createfORM

3. Select Database, and Click on Next

selectwizard

4. Click on New Connection

connectDB

5. Now Choose DataSource, Click on Continue

datasource

6. Browse For the Database. Provide Username, Password, if any

add connection

7. Click On Test Connection

8. If all is Ok, Click Previous, Copy the Connection String, and Click Cancel, Delete DataGridView if you don't need it

database string

Oracle Connection String

Following is the Correct Format of Oracle Database Connection

using Oracle.ManagedDataAccess.Client;

public void Execute(string queryString, string connectionString)
{
    using (OracleConnection connection = new OracleConnection(connectionString))
    {
        OracleCommand command = new OracleCommand(queryString, connection);
        command.Connection.Open();
        command.ExecuteNonQuery();
    }
}

(For Detailed Study of Connection Strings)

Do suggest/Comment, Help Others


Similar Articles