问题描述
使用下面的代码连接到SQL服务器,并使用用户"john"连接一半的用户。从查询字符串和连接正常,但其他人使用相同的查询字符串但忽略userID并使用他们的Windows ID代替。
有没有其他人遇到这个以及为什么它会忽略userID?
谢谢,
约翰
(SqlConnection connection = style ="color:blue"> new SqlConnection(" Data Source = sqlServer; Database = dbName; User Id = john; Password = pass123;")){
connection。打开();
//在这里工作;连接在以下行关闭。
connection.Close();
}
https://msdn.microsoft .com / zh-cn / library / system.data.sqlclient.sqlconnection(v = vs.110).aspx
Using the code below to connect to a SQL server and for half the users it connects using the user "john" from the query string and connects fine but others its using the same query string but ignores the userID and uses their windows id instead.
Has anyone else come across this and why it ignores the userID?
Thanks,
John
using (SqlConnection connection = new SqlConnection("Data Source=sqlServer;Database=dbName;User Id=john;Password=pass123;")) {
connection.Open(); // Do work here; connection closed on following line.
connection.Close();
}
https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection(v=vs.110).aspx
这篇关于SQL连接字符串忽略UserID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!