Monday, March 26, 2012

problem in connectionstring

when I write this code in web.config :

<configuration><appsettings><addkey="constring" VALUE="WORKSTATION id=I-85096B7FC8F64;packet catalog='test"/' info="True;initial" security="SSPI;data" source="I-85096B7FC8F64;persist" size="4096;integrated"><system.web>

and write this statements in the code of program :

string Constring = ConfigurationSettings.AppSettings("constring"); SqlConnection conn = new SqlConnection(constring);

this error is displyed:

The name 'constring' does not exist in the class or namespace 'C_sharp1.WebForm1'

In C#, instead of:
ConfigurationSettings.AppSettings("constring")
use square brackets:
ConfigurationSettings.AppSettings["constring"]|||

thanks a lot.

the problem is solved by your solution.

No comments:

Post a Comment