Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Configuration File

Status
Not open for further replies.

sp76

Programmer
Jul 1, 2003
59
AU
How can I use configuration file to provide connection string for my SQL Server database?
 
you have to add a key under the application settings section
ex:
<!-- application specific settings -->
<appSettings>
<add key="ConnectionString" value="server=you server;User ID=sa;pwd=passowrd;database=dbname" />
</appSettings>

Then you can call the connection string from any function or event from your app.

ex:

Dim myConnection As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))

Martin
 
where is application settings section is that my .config file do u mean?

will i be writing the following code in my .config file?
<!-- application specific settings -->
<appSettings>
<add key="ConnectionString" value="server=you server;User ID=sa;pwd=passowrd;database=dbname" />
</appSettings>

I don't want to hard code userid and password as user will providing them through a Login Screen in the application?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top