简体   繁体   English

如何使用受信任的连接正确访问我的SQL Server数据库?

[英]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;

Sql Connection Strings Sql连接字符串

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.

相关问题 如何在不使用trusted_connection的情况下从Windows连接到SQL Server? - How do I connect to SQL Server from Windows without using trusted_connection? 可信的SQL Server连接 - trusted SQL Server connection 远程数据访问:用户未与可信的SQL Server连接关联 - Remote Data Access: the user is not associated with a trusted SQL Server connection 从Microsoft Access到VM上SQL Server的可信连接 - Trusted connection to SQL Server on VM from Microsoft Access 如何使用证书保护SQL Server数据库连接的安全? - How do I secure SQL Server database connection using certificate? 如何使用Visual Studio 2008工具向特定用户授予对SQL Server Express数据库的访问权限? - How do I grant access to my SQL Server Express database to a specific user with Visual Studio 2008 tools? 如何将对SQL Server数据库的访问限制为特定IP? - How do I limit access to my SQL Server database to specific IP? 如何正确地将我的 SQL 服务器数据库链接到 Access 表单并将其分发到网络并让他们输入信息? - How can I properly link my SQL Server database to an Access form and distribute it to the network and have them input information? PHP:如何建立与 SQL Server 的连接? - PHP: How do I establish a connection to my SQL Server? 用户登录失败(使用可信连接 EF Core) 如何创建丢失的数据库? - Login failed for user ( with trusted connection EF Core) How do I create missing database?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM