connection string in web.config error

M

Matt

I added the connection string in web.config as follows:

<appSettings>
<add key="connString" value="Integrated Security=SSPI;Persist Security
Info=False;Initial Catalog=MY_DATABASE;Data Source=IP_ADDRESS" />
</appSettings>

In mypage.aspx.vb page, I open the connection with connString variable:

Dim conn As New SqlConnection(connString)

But it has compile error:
name 'connString' is not declared.

Any ideas?
 
A

Andrew de la Harpe

System.Configuration.ConfigurationSettings.AppSettings["connString"]

will return it

Consider creating a class that returns your connection string. That way if
later you decided to change your method of storing the string, the change is
simple.

Andrew
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top