以下连接数据库代码
private void button1_Click(object sender, System.EventArgs e)
{
SqlConnection conn = new SqlConnection("Persist Security Info=False;Integrated Security=True;Initial Catalog=php;Data Source=william;");
try
{
conn.Open();
MessageBox.Show("连接成功");
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
提出出错信息,截图请各位大侠帮忙检查。

解决方案 »

  1.   

    错误提示框:
    在建立与服务器的连接时出错。在连接到SQL Server 2005时,在默认的设置下SQL Server 不允许进行远程连接可能会导致此失败。(provider:命名管道提供程序,error:40 -无法打开到SQL Server的连接
      

  2.   

    http://www.ej38.com/showinfo/csharp-sql-186951.html
      

  3.   

    你改成这个试试:
    Data Source=.\SQLEXPRESS;Initial Catalog=SendSms;Integrated Security=True"
    SqlConnection conn = new SqlConnection("Data Source=.\\SQLEXPRESS;Initial Catalog=SendSms;Integrated Security=True"