我知道这是一个很标准的问题......但是我无法解决它。
所以这是我想做的:
我想通过Windows身份验证连接到我的本地SQL Server .\SQLEXPRESS。我可以使用SQL Server Management Studio进行登录。
我的连接字符串如下:
string connStr = "Provider=SqlOleDB;Data Source=.\\SQLExpress; Initial Catalog=Sports; Integrated Security=SSPI";
它抛出了一个错误:
Cannot open database "Sports" requested by the login. The login failed.
所以我尝试了:
string connStr = "Provider=SqlOleDB;Data Source=.\\SQLExpress; Initial Catalog=Sports; Trusted_Connection=True";
它给了我:
Invalid authorization specification
然后我尝试了:
string connStr = "Provider=SqlOleDB;Data Source=.\\SQLExpress; Initial Catalog=Sports; Integrated Security=True";
它返回:
No error message available, result code: DB_E_ERRORSOCCURRED(0x80040E21).
有什么想法吗?
更新:我忘了提到,我正在使用运行SQL Server 2010 Express的虚拟机Windows 7。这与虚拟机有关吗?