我正在尝试使用 visual studio 2010 运行以 C# 编写的控制台应用程序 我正在其中访问 Microsoft Sql Server Managment Studio 的临时数据库。
但是应用给出异常如下:
"Cannot open database "dbname" requested by the login. The login failed. Login failed for user `machinname\username""
我的连接字符串如下:
con.ConnectionString = @"Data Source=.\SQLEXPRESS;Initial Catalog=temp;Integrated Security=True";
为什么会因为这样的错误而失败?
最佳答案
运行该应用程序的用户(可能是您,因为这是一个控制台应用程序)没有数据库的登录权限。
Integrated Security=True
表示正在使用 Windows 身份验证 - 使用对数据库具有适当权限的用户,或向用户授予适当的权限。
关于c# - 无法打开登录请求的数据库 "dbname"。登录失败。用户 "machinname\username"登录失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5558192/