Solved

connection info in the configuration file

Posted on 2009-04-03
2
130 Views
Last Modified: 2012-05-06
hi

where to store the connection info in the configuration file of a project and how to read it ?
0
Comment
Question by:Pure_Heart
  • 2
2 Comments
 
LVL 53

Expert Comment

by:Dhaest
ID: 24058886
Read connection string from web.config
http://snippets.dzone.com/posts/show/1343

Custom Configuration SQL Connection String Section
http://www.codeproject.com/KB/database/CustomConfigSqlConn.aspx
0
 
LVL 53

Accepted Solution

by:
Dhaest earned 125 total points
ID: 24058891
In your app.config
<configuration>
<appSettings>
      <add key="connectionString" value="server=servername;database=dbname;integrated security=sspi" />
 
</appSettings>
</configuration>


To reference that in your code:

Dim oConn As New SqlConnection(ConfigurationSettings.AppSettings("connectionString"))
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now