[英]How do I properly access my SQL Server database with trusted connection?
Dim connString As String = "Server=(LocalDB)\MSSQLLocalDB;Database=Database1.mdf;Trusted_Connection=True"
Dim cnn As New SqlConnection(connString)
cnn.Open()
I am using the above code in my program and the connection seems to work but for some reason it says 我在程序中使用了上面的代码,连接似乎正常,但是由于某种原因它说
Cannot open database "Database1.mdf" requested by the login.
无法打开登录请求的数据库“ Database1.mdf”。 The login failed.
登录失败。 Login failed for user 'Alex\\John'.
用户“ Alex \\ John”的登录失败。
I have no clue why it won't let me log in since i set it as trusted. 我不知道为什么我将其设置为受信任后为什么不允许我登录。 Is there something behind the scenes that I am missing?
幕后有什么我想念的吗?
You are connecting to a mdf
. 您正在连接到
mdf
。 That is the database file, you need to connect to a server 那是数据库文件,需要连接到服务器
Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;
connectionString="Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Database1.mdf;Data Source=Alex-PC;"
connectionString="Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Database;Data Source=Alex-PC
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.