Click here to Skip to main content
11,932,402 members (57,230 online)
Click here to Skip to main content
Add your own
alternative version


45 bookmarked

Get DataBase Connection Strings in an Easy Way

, 27 Sep 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
Communication with database in .NET is easy but sometimes one gets stuck by wrong format of connection string


In computing, a connection string is a string that specifies information about a data source and the means of connecting to it. It is passed in code to an underlying driver or provider in order to initiate the connection. Whilst commonly used for a database connection, the data source could also be a spreadsheet or text file.

The connection string may include attributes such as the name of the driver, server and database, as well as security information such as user name and password (source Wikipedia[^]).

UDL file can be used to generate connection strings easily.

How to make UDL file?

  1. Make a text file, open it.
  2. Click on Save As.
  3. Write filename as something.udl, file type All files, click Save.
  4. Now run something.udl.
  5. Click on Provider tab. Select the provider and click Next.
  6. Give the DataBase Path, Give Username, Password, if any.
  7. Click on Test Connection.

If it's OK, then close it now.

Now open udl file as text file, connection string will be there in the last line.

Following is the connection string format for Oracle:

private static string CONNECTION_STRING =
"User Id=myUserID;Password=myPassword;Data Source=(DESCRIPTION=" +

An alternate way of doing it is as follows:

  1. Add DataGridView in your Form.
  2. Provide DataSource by browsing, do the Settings, once all done, don't click OK, go back to the first step by clicking Previous.
  3. Click on Show Connection String.
  4. Copy it, and use where you want.

For more details with screenshots, see MY article Connection Strings[^].

Following are the links to websites which provide Connection Strings Format for various DBMS:


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Pakistan Pakistan
I am programming learner.

You may also be interested in...

Comments and Discussions

GeneralThanks a lot ! That's exactly what I was looking for. I kne... Pin
Eric Ouellet11-Oct-11 4:06
memberEric Ouellet11-Oct-11 4:06 
GeneralReason for my vote of 5 Maybe old hat to some. New to me. Pin
wbherdle13-Jul-11 8:31
memberwbherdle13-Jul-11 8:31 
Generalthere is no article at link specified by you...... http://ww... Pin
Pritesh Aryan16-May-11 1:18
memberPritesh Aryan16-May-11 1:18 
GeneralThanks for the tip. I've only seen this one time before; I ... Pin
Keith.Badeau1-Apr-11 9:34
memberKeith.Badeau1-Apr-11 9:34 
GeneralReason for my vote of 5 nice tip Pin
jvillamil28-Mar-11 19:24
memberjvillamil28-Mar-11 19:24 
GeneralDidn't see this posted yet, but someone might find it useful... Pin
Torrey Betts23-Mar-11 11:39
memberTorrey Betts23-Mar-11 11:39 
GeneralReason for my vote of 1 Rehashed a thousand times on the web... Pin
Dave Kreskowiak2-Mar-11 10:12
mvpDave Kreskowiak2-Mar-11 10:12 
GeneralReason for my vote of 4 different kind of approach. Pin
Kumar_P1-Mar-11 7:54
memberKumar_P1-Mar-11 7:54 
GeneralReason for my vote of 5 it is something Different new i thin... Pin
bipin91-Mar-11 0:03
memberbipin91-Mar-11 0:03 
GeneralRe: Actually, it's not rare at all. It's the most common method... Pin
Dave Kreskowiak2-Mar-11 10:11
mvpDave Kreskowiak2-Mar-11 10:11 
GeneralReason for my vote of 1 Doesn't add to the sum total of huma... Pin
damnedyankee24-Feb-11 6:29
memberdamnedyankee24-Feb-11 6:29 
GeneralReason for my vote of 5 I like it Pin
RaviRanjankr17-Feb-11 21:20
mvpRaviRanjankr17-Feb-11 21:20 
GeneralRe: Thnx dear Pin
Abdur Rehman Raza Khan - dontumindit20-Feb-11 5:27
memberAbdur Rehman Raza Khan - dontumindit20-Feb-11 5:27 
Generalthnx dear, lets keep helping others Pin
Abdur Rehman Raza Khan - dontumindit17-Feb-11 1:49
memberAbdur Rehman Raza Khan - dontumindit17-Feb-11 1:49 
GeneralReason for my vote of 5 Very nice trick. My 5 Pin
Pravin Patil, Mumbai16-Feb-11 23:02
memberPravin Patil, Mumbai16-Feb-11 23:02 
QuestionI liked it Pin
Shivprasad koirala15-Nov-11 1:30
mvpShivprasad koirala15-Nov-11 1:30 
Generalnice beginner tip Pin
Simon_Whale24-May-11 7:01
memberSimon_Whale24-May-11 7:01 
GeneralA handy tip ... Pin
Peter Hayward21-Mar-11 14:24
memberPeter Hayward21-Mar-11 14:24 
GeneralAnother useless article Pin
damnedyankee24-Feb-11 6:17
memberdamnedyankee24-Feb-11 6:17 
GeneralRe: Another useless article Pin
Abdur Rehman Raza Khan - dontumindit26-Feb-11 22:53
memberAbdur Rehman Raza Khan - dontumindit26-Feb-11 22:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.151126.1 | Last Updated 27 Sep 2013
Article Copyright 2011 by dontumindit
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid