C# SqlConnection连接 error:40


1. 用SqlConnection 连接SQLServer数据库

try
{
string sqlConn = "server=DELL-PC/SQLEXPRESS1;database=OPGWDB;uid=sa;pwd=sa";
SqlConnection conn = new SqlConnection(sqlConn);
conn.Open();

DataTable dt = new DataTable();
string sql = "Select * from dbo.Yhjsb";
SqlDataAdapter ad = new SqlDataAdapter(sql, conn);
ad.Fill(dt);

conn.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex);
}

 2. 但是一直报如下错误

3. 确保客户端登录没问题

4. 然后string sqlConn = @"server=DELL-PC\SQLEXPRESS1;database=OPGWDB;uid=sa;pwd=sa";  问题解决

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM