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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

connection string error

Status
Not open for further replies.

nnmmss72

Programmer
May 14, 2006
110
IR
i am defining the connection string in 2 methods,
the first which works fine is like that

private void Button_Click(object sender, System.EventArgs e)
{
CommonFunction myObject;
SqlConnection myConnection= new SqlConnection("server=(local)\\NetSDK;database=kach;uid=webapp;pwd=1234");
myConnection.Open()
}

the second one is by using the web.config so that i should just define it in just one page(web.config)


private void Button_Click(object sender, System.EventArgs e)
{
string connectionInfo = ConfigurationSettings.AppSettings["ConnectionInfo"];
SqlConnection myConnection = new SqlConnection(connectionInfo);
myConnection.Open()
}

and i have define the connectionstring in web.config like this

<appSettings>
<add key="ConnectionInfo" value="server=(local)\\NetSDK;database=kach;uid=webapp;pwd=1234" />
</appSettings>

but in second method it says that sql server doesn't exist or access denied, the information (userId,password,database) are the same , so why does this happen?
 
<appSettings>
<add key="ConnectionInfo" value="server=(local)\NetSDK;database=kach;uid=webapp;pwd=1234" />
</appSettings>


there was an extra \

Known is handfull, Unknown is worldfull
 
when written in C# it had to be escaped...

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top