Compartir a través de


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!