L
lauralucas
Hello
I'm trying to use a connection string stored in web.config
here is the web.config part
<appSettings>
<add key="NDDbase"
value="Server=SOMESERVER\\SOMEINSTANCE;integrated
security=SSPI;database=NDD"/>
</appSettings>
and from code I'm trying to access it like this:
string mySelectQuery = "SELECT * FROM sometable'";
string myConnectString = ConfigurationSettings.AppSettings["NDDbase"];
SqlCommand myCommand = new SqlCommand(mySelectQuery);
myCommand.Connection = new SqlConnection(myConnectString);
But when debugging, I see that myConnectString value always starts with
an @, like this:
@"Server=SOMESERVER\\SOMEINSTANCE;integrated
security=SSPI;database=NDD"
is this normal? I could parse the string and remove the at-sign but I
suppose is there for a reason. This makes the SqlConnection to not
open, as it is not initialized properly.
help me and write me some suggestions please, thanks =)
Regards
Laura Lucas
I'm trying to use a connection string stored in web.config
here is the web.config part
<appSettings>
<add key="NDDbase"
value="Server=SOMESERVER\\SOMEINSTANCE;integrated
security=SSPI;database=NDD"/>
</appSettings>
and from code I'm trying to access it like this:
string mySelectQuery = "SELECT * FROM sometable'";
string myConnectString = ConfigurationSettings.AppSettings["NDDbase"];
SqlCommand myCommand = new SqlCommand(mySelectQuery);
myCommand.Connection = new SqlConnection(myConnectString);
But when debugging, I see that myConnectString value always starts with
an @, like this:
@"Server=SOMESERVER\\SOMEINSTANCE;integrated
security=SSPI;database=NDD"
is this normal? I could parse the string and remove the at-sign but I
suppose is there for a reason. This makes the SqlConnection to not
open, as it is not initialized properly.
help me and write me some suggestions please, thanks =)
Regards
Laura Lucas