使用IntegratedSecurity时获取SSL提供程序错误

时间:2012-10-21 08:19:43

标签: c# asp.net sql-server-2008

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();

但是我得到了以下错误:

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();

但是我得到了以下错误: 用户代码

未处理SqlException

建立与SQL Server的连接时发生与网络相关或特定于实例的错误。服务器未找到或无法访问。验证实例名称是否正确,以及SQL Server是否配置为允许远程连接。 (提供者:命名管道提供程序,错误:40 - 无法打开与SQL Server的连接)

请帮助我理解错误并纠正错误。

1 个答案:

答案 0 :(得分:0)

确保在SQL Server配置管理器中启用了TCP / IP:Enable Network Access in SQL Server Configuration Manager

此外,启动SQL Server Browser服务:Start and Stop the SQL Server Browser Service