Solved

connection info in the configuration file

Posted on 2009-04-03
2
133 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.Net WebRequest Code from JSON curl 7 84
VB.Net. Reading xml value 6 36
VB.net Open video relating to control 2 29
How to repeat the data 4 30
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…

680 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