我正在尝试使用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""
Run Code Online (Sandbox Code Playgroud)
我的连接字符串如下:
con.ConnectionString = @"Data Source=.\SQLEXPRESS;Initial Catalog=temp;Integrated Security=True";
Run Code Online (Sandbox Code Playgroud)
为什么这会因为这样的错误而失败?
运行应用程序的用户(可能是因为这是一个控制台应用程序),对数据库没有登录权限.
Integrated Security=True 表示正在使用Windows身份验证 - 使用对数据库具有适当权限的用户,或向用户授予适当的权限.
| 归档时间: |
|
| 查看次数: |
17009 次 |
| 最近记录: |