代码如下:
        
<%@ Import Namespace="System.Data"%>
<%@ Import Namespace="System.Data.SqlClient"%>
<script language="c#" runat="server">
   void Page_Load()
    {
       SqlConnection thisConnection=new SqlConnection(@"Data Source=(local);Integrated Security=SSPI;Initial Catalog=northwind");
       thisConnection.Open();
       SqlDataAdapter thisAdapter=new SqlDataAdapter("select CustomerID,CompanyName from Customers",thisConnection);
      
       SqlCommandBuilder thisBuilder=new SqlCommandBuilder(thisAdapter);
       DataSet thisDataSet=new DataSet();
       thisAdapter.Fill(thisDataSet,"Customers");
       
       DataGrid1.DataSource=thisDataSet.Tables["Customers"].DefaultView;
       DataGrid1.DataBind();
   }
</script>
<html>
<head>
    <title Data Grid Control example</title>
</head>
<body>
  <asp:DataGrid id="DataGrid1" runat="server"/>
</body>
</html>运行后一直提示登陆失败,好郁闷。不知道哪里出问题了。大侠们快来帮帮小弟啊

解决方案 »

  1.   

    Integrated Security=SSPI;
    这个不对吧.
      

  2.   

    SqlCommandBuilder thisBuilder=new SqlCommandBuilder(thisAdapter);
    上面这步可以省略吧连接字符串中的sa pwd?
      

  3.   

    有两种改法:
    1 在SqlServer上执行下列语句
    sp_grantlogin '你的计算机名\ASPNET'
    GO
    sp_grantdbaccess '你的计算机名\ASPNET', 'myuser'
    GO
    sp_addrolemember  'db_owner', 'myuser'
    GO2.将Integrated Security=SSPI删除,改为SqlServer 用户名和密码
      

  4.   

    2.将Integrated Security=SSPI删除,改为SqlServer 用户名和密码
    这个的格式是怎么写的,麻烦高手再说一下了.是:SqlServer=我的用户名&我的密码  这样写吗.谢谢
      

  5.   

    SqlConnection oSQLConn = new SqlConnection();
    oSQLConn.ConnectionString="Driver={SQL Server};Server=computer or ip;Database=pubs;Uid=sa;Pwd=asdasd;" 
    oSQLConn.Open();
      

  6.   

    SqlConnection oSQLConn = new SqlConnection();
    oSQLConn.ConnectionString="Driver={SQL Server};Server=计算机名或IP;Database=数据库名;Uid=用户名;Pwd=密码;" 
    oSQLConn.Open();
      

  7.   

    比如:
    User ID=sa;Pwd=sa账号的密码
      

  8.   

    Data Source=(local) 这个不对吧,应该是
    Data Source=localhost
      

  9.   

    一定是这句的问题,后果很严重
    SqlConnection thisConnection=new SqlConnection(@"Data Source=(local);Integrated Security=SSPI;Initial Catalog=northwind");看看这个你就明白怎么建立连接了
    http://www.connectionstrings.com/
      

  10.   

    呵呵,不好意思,这个是错的:
    Data Source=(local) 这个不对吧,应该是
    Data Source=localhost(local)是对的,localhost在XP下不能用,2000上可以。你代码的其它地方没看出有什么错误,你再检查一下其它地方。
      

  11.   

    如果你采用的是windows集成验证,就使用Integrated Security=SSPI连接,如果是混合验证,就使用uid=sa,pwd=""来连接
      

  12.   

    用Server=.
    和Server=127.0.0.1试试.