我知道这是一个相当标准的问题......但无法弄清楚..SQL Server 2008中的连接字符串错误
所以这里就是我想要做的:
我想连接到我的本地SQL服务器。\ SQLEXPRESS通过Windows身份验证。我可以通过使用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。有没有什么与虚拟机?
是的。我使用VS Web Developer 2010 .. – sbs 2010-11-16 21:50:35