我目前正在使用C#通過Visual Studio 2012和SQL Server 2012管理工作室執行我的最後一年大學項目。由於連接到我的計算機上的SQL Server,因此無法在家中嘗試在我的項目上工作。在課堂上,我們已經設置使用資源的連接字符串:使用資源的C#SQL連接字符串
名稱:conStr
值:Data Source = localhost;Initial Catalog = computer warehouse;Integrated Security = true
而且使用
cnStr = Properties.Resources.conStr;
sqlCustomers = @"Select * from Customers";
daCustomer = new SqlDataAdapter(sqlCustomers, cnStr);
cmdCustomers = new SqlCommandBuilder(daCustomer);
daCustomer.FillSchema(dsCustomer, SchemaType.Source, "Customers");
daCustomer.Fill(dsCustomer, "Customers");
在窗體加載
我有兩個SQL服務器和Visual Studio在我的家庭計算機上,並通過Visual Studio創建了連接,在SQL上創建了數據庫和accuired新的連接字符串
Data Source=NIALL\SQLEXPRESS;Initial Catalog=computer warehouse;Integrated Security=True
然而,當我運行程序我得到這個錯誤
類型「System.Data.SqlClient.SqlException」的第一次機會異常出現在System.Data.dll中
更多信息告訴我的服務器未找到或無法訪問
任何幫助表示讚賞
如果你家裏沒有SQL express,連接字符串是錯誤的......也許你安裝了不同的版本? –
我99%肯定他們是相同的版本,我們有從課堂上下載的鏈接。 Visual Studio和SQL Server都安裝在我的機器上。這是我真的無法得到我的頭,並將不得不研究更多 – Sqoh
不用擔心,請嘗試:select @@ version –