Freigeben über


VS 2003 Tip #13: Getting a connection string quickly

Often I will be writing some quick code to access a database, and I'll need to add a connection string to get this. Heres a quick way to get the connection string using VS:

Open Server Explorer. Right click on Data connections and select “Add new connection”. Pass the information that you want to connect with to the dialog. Hit ok. Once this connection gets added to your Data Connection, right click on it and select Properties. The properties window opens up and one of the fields in it (conveniently) is Connect String. Copy and Paste it into your code. You can trim it down further if you happen to know more details about it. Voila!

Comments

  • Anonymous
    April 13, 2004
    Bad... Bad ... Bad ...

    Take a look on OLE DB IDBPromptInitialize interface.
    C++ users (as well some others ;o) can use it to show nice connection dialogs in their applications.

    Also I've made suggestion to allow .NET (C# for example) developers to be able do the same. Microsoft most likely will add this in Beta 1 of Whidbey.



  • Anonymous
    April 13, 2004
    Sorry - but for my benefit, what exactly is bad?
  • Anonymous
    April 14, 2004
    I do it like this: Go to desktop, create new text file, change extension to .udl, double click, do what you have to, change back to .txt or throw in *pad.
  • Anonymous
    May 12, 2004
    The comment has been removed
  • Anonymous
    May 28, 2004
    The comment has been removed
  • Anonymous
    June 16, 2009
    PingBack from http://fixmycrediteasily.info/story.php?id=4189