我知道這是一個相當標準的問題......但無法弄清楚..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