简体   繁体   中英

connection string issue with SQL EXPRESS 2008

I have a connection string in c# that cant connect to my instance running on studio express 2008. Both the application and the database are on the same machine. I have mixed mode on, and my instance name (found in my registry) is SqlExpress. I can log into the database with my user name and password but not in my connection string.

SqlConnection("Data Source=.\\SqlExpress;" + "Initial Catalog=test;"
+ "Integrated Security=false;" + "User Id=test;" 
+ "Password=test;" + "connection timeout=300;" + "pooling=false;");

Try:

SqlConnection cn = new 
    SqlConnection(@"Server=.\SQLExpress;Database=test;"
    +"Connection Timeout=300;User ID=test;Password=test;Pooling=false")

Try below

using (System.Data.SqlClient.SqlConnection con = new SqlConnection("Server=myServerAddress;Database=myDataBase;User ID=myUsername;Password=myPassword;Trusted_Connection=False;"))
{
}

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM