我想要用C#連接數(shù)據(jù)庫,數(shù)據(jù)庫是用Windows方式連接的,能成功連接,服務名稱是localhost,數(shù)據(jù)庫名稱是圖書館管理系統(tǒng),打完代碼,運行提示:An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dllAdditional information: 用戶 '' 登錄失敗。(我是用Windows方式連接的,為什么用這個錯誤去查,網(wǎng)上都是說的用戶名密碼登錄那些?)代碼如下:?string str = "data source=localhost;Initial Catalog=圖書館管理系統(tǒng);Integrated Security=True";? ? ? ? ? ? SqlConnection con = new SqlConnection(str);? ? ? ? ? ? con.Open();//在這里停下提示上面的問題? ? ? ? ? ? if (con.State ?== ConnectionState.Open)? ? ? ? ? ? {? ? ? ? ? ? ? ? MessageBox.Show("成功連接,第一步完成");? ? ? ? ? ? }
求大神幫忙看看,我在網(wǎng)上找了好久,沒找到答案?
someOne_forward
2017-06-10 11:38:49