string sqlStr = "select * from student";                SqlConnection myConnection = new SqlConnection("workstation id=All;packet size=4096;User Id=sa;Password=sa;data source=local;persist security info=True;initial catalog=Examonline;Max Pool Size=500;Min Pool Size=5");
                SqlCommand  thisCommand = new SqlCommand(sqlStr, myConnection);                myConnection.Open();//执行到这句是出错 我装的是sql2000在建立与服务器的连接时出错。
在连接到 SQL Server 2005 时,在默认的设置下 SQL Server 不允许进行远程连接可能会导致此失败。 
(provider: 命名管道提供程序, error: 40 - 无法打开到 SQL Server 的连接)

解决方案 »

  1.   

    SqlConnection myConnection = new SqlConnection("workstation id=All;packet size=4096;User Id=sa;Password=sa;data source=(local);persist security info=True;initial catalog=Examonline;Max Pool Size=500;Min Pool Size=5"); 
                    SqlCommand  thisCommand = new SqlCommand(sqlStr, myConnection); ---------------------
    把 local 加个 () 试一试
      

  2.   

    SqlConnection myConnection = new SqlConnection("workstation id=All;packet size=4096;User Id=sa;Password=sa;data source=local;persist security info=True;initial catalog=Examonline;Max Pool Size=500;Min Pool Size=5;trusted_connection=true"); 
    试试看