偶滴程序如下:
  <script laguage="VB" runat="server">
sub page_load(sender as Object,e as EventArgs)
  Dim myConnection As SqlConnection
  Dim myCommand As SqlCommand
  Dim ds as DataSet 
  
  myConnection = New SqlConnection( "server=localhost;database=Pubs;uid=sa;pwd=''" )
  myConnection.Open()
  la1.text="Connection Opened!"
  
  myCommand = New SqlCommand( "select * from employee",myConnection)
  MyDataGrid.DataSource=myCommand.ExecuteReader()
  MyDataGrid.DataBind()
end sub
</script>可执行到myConnection.Open就出错
[SqlException: SQL Server 不存在或访问被拒绝。]
   System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction)
   System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction)
   System.Data.SqlClient.SqlConnection.Open()
   ASP.WebForm1_aspx.page_load(Object sender, EventArgs e) in c:\inetpub\wwwroot\WebApplication2\WebForm1.aspx:11
   System.Web.UI.Control.OnLoad(EventArgs e)
   System.Web.UI.Control.LoadRecursive()
   System.Web.UI.Page.ProcessRequestMain()并且SQL连接模式为SQL Server And Windows
请问那里出错了?

解决方案 »

  1.   

    "server=(local);database=Pubs;uid=sa;pwd='密码没有吗?'"
      

  2.   

    1.你的连接字符串有问题
    2。你用command是取不出数据来的,用sqldataadapter
    然后 fill(ds)
      

  3.   

    Sql Server 有没有启动呢?
      

  4.   

    Server=localhost; initial catalog=Pubs; user id=sa; pwd=****
      

  5.   

    "server=(local); User ID=sa;Password=;database=pubs"在这前请保证你用查询分析器可以联接,还有就是最好能打上sql Sp3或者sp4补丁
      

  6.   

    贴个范例:
    private void BindDataGrid()
    {
    SqlConnection myConnection = new SqlConnection("server=localhost;database=Test;uid=sa;pwd=123456");
    SqlCommand myCommand = new SqlCommand("select * from person", myConnection);
    myConnection.Open();
    SqlDataReader dr = myCommand.ExecuteReader();
    MyDataGrid.DataSource = dr;
    MyDataGrid.DataBind();
    myConnection.Close();

    }
      

  7.   

    如果你的操作系统是XPSP2或则是2003的话,应该安装SQLSP3升级包,因为1433端口被屏蔽掉了
    你可以用netstat -an 查看1433端口是否打开
    你也可以打开开始-->程序--Microsoft Sql Server-->服务器网络实用工具
    然后启用WinSock代理,代理地址为127.0.0.1,代理端口为1433,这样也可以打开1433端口
    记住用netstat -an 查看1433端口的开启情况