I am new to asp.net. Here is my issue. Please help.
I am trying to connect to my database which is also on the local machine as my asp.net project. I am using the following connection string
SqlConnection con = new SqlConnection("Data Source= NGEST1AND2\SQLEXPRESS;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=False");
I get an error under SQLEXPRESS (Unrecognised escape sequence) . I tried to rectify this error with a \\\\
and then the error goes away but I get another error saying unable to connect to database.
Ay help will be greatly appreciated.
Thanks Gerard
SqlConnection con = new SqlConnection(@"Data Source= NGEST1AND2\SQLEXPRESS;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=False");
放在@开头
try this
SqlConnection con = new SqlConnection(@"Data Source= NGEST1AND2\SQLEXPRESS;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=False");
Put @
before your connection string.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.