SqlConnection cnn = new SqlConnection();
cnn.ConnectionString = "Data Source=.;Database = deptStore;Integrated Security = true;";
cnn.Open();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "insert into Employee values('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "','" + TextBox5.Text + "','" + TextBox6.Text + "','" + TextBox7.Text + "','" + TextBox8.Text + "','" + TextBox9.Text + "','" + TextBox10.Text + "','" + TextBox11.Text + "','" + TextBox12.Text + "','" + TextBox13.Text + "')";
cmd.Connection = cnn;
cmd.ExecuteNonQuery();
Response.Write("Record Save");
cnn.Close();
連接,但我收到以下錯誤:試圖建立與SQL Server 2008
SqlException was unhandled by user code
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
請幫助我理解的錯誤並糾正它。
我投票結束這個問題 - 很多人給出瞭解決方案,你所做的只是說「不工作」。你必須參與並閱讀答案並回答他們的答案。 **我們將無法解決這個問題如果您所做的只是複製一個連接字符串和報告它不起作用** – Hogan