语法看起来没错,是不是trusted connection有问题,你不用信任连接试试看。。

解决方案 »

  1.   

    不好意思,打错了
    报错的是myCommand.Fill(ds, "person");还有一长串看不懂得东西
    SqlException: 用户 'KEVIN\ASPNET' 登录失败。]
       System.Data.SqlClient.SqlConnection.Open()
       System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState)
       System.Data.Common.DbDataAdapter.Fill(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
       System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
       System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
       WebApplication4.WebForm1.Button_CONNECT_Click(Object sender, EventArgs e) in d:\inetpub\wwwroot\webapplication4\webform1.aspx.cs:64
       System.Web.UI.WebControls.Button.OnClick(EventArgs e)
       System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
       System.Web.UI.Page.ProcessRequestMain()
    这是什么原因?
      

  2.   

    server=(local);database=ASPTest;Trusted_Connection=yes
    这行有错
    sever=?;initial catalog=?;user id=?;password=?把这四项填全
      

  3.   

    server=(local);database=ASPTest;Trusted_Connection=yes
    这行有错?
    不会吧,大哥
    微软的例子就这么写的
    SqlConnection myConnection = new SqlConnection("server=(local)\\NetSDK;database=pubs;Trusted_Connection=yes");
    我对sql sever用的不熟
    但是好像用的是与windows一样的认证方式,并没有添加什么用户

      

  4.   

    protected System.Data.SqlClient.SqlConnection MyConn=new SqlConnection();
    protected System.Data.SqlClient.SqlCommand MyCommand=new System.Data.SqlClient.SqlCommand();
    protected System.Data.DataSet MyDataSet=new System.Data.DataSet();
    protected System.Data.SqlClient.SqlDataAdapter MyDataAdapter=new System.Data.SqlClient.SqlDataAdapter();
    这就是非信任连接
    this.MyConn.ConnectionString="data source=it_server;initial catalog=erf_2000;persist security info=False;user id=hut;password=hut2000;workstation id=JACKY;packet size=4096";
    =this.DbConStr();  
    this.MyCommand.Connection=MyConn;
    this.MyCommand.CommandType=CommandType.Text;
    this.MyCommand.CommandText="select * from mytable";
    this.MyDataAdapter.SelectCommand=this.MyCommand; this.MyDataAdapter.Fill(MyDataSet);
      

  5.   

    protected System.Data.SqlClient.SqlConnection MyConn=new SqlConnection();
    protected System.Data.SqlClient.SqlCommand MyCommand=new System.Data.SqlClient.SqlCommand();
    protected System.Data.DataSet MyDataSet=new System.Data.DataSet();
    protected System.Data.SqlClient.SqlDataAdapter MyDataAdapter=new System.Data.SqlClient.SqlDataAdapter();
    这就是非信任连接
    this.MyConn.ConnectionString="data source=it_server;initial catalog=erf_2000;persist security info=False;user id=hut;password=hut2000;workstation id=JACKY;packet size=4096";
    =this.DbConStr();  
    this.MyCommand.Connection=MyConn;
    this.MyCommand.CommandType=CommandType.Text;
    this.MyCommand.CommandText="select * from mytable";
    this.MyDataAdapter.SelectCommand=this.MyCommand; this.MyDataAdapter.Fill(MyDataSet);
      

  6.   

    server=localhost;initial catalog=ASPTest;user id=sa
    这样试一下
      

  7.   

    SqlException: 用户 'KEVIN\ASPNET' 登录失败。]
    这个问题的解决方法我记得以前有人说过,我忘记了,你可以去已解决问题专区去看看。。
      

  8.   

    我还想随便问一下
    在vs.net里如何添加一个Page_Load函数
    像vc里class wizard那样,而不是手工添加?
      

  9.   

    用系统管理员就可以了要不然在数据表的 属性里有权限选项
    将asp.net加入即可
      

  10.   

    sql sever的默认系统管理员用户名和密码是什么?
      

  11.   

    连接语句改成
    SqlConnection myConnection = new SqlConnection("server=(local);database=ASPTest;uid=sa;pwd=");
    还是报错“用户 'sa' 登录失败。原因: 未与信任 SQL Server 连接相关联”
      

  12.   

    报错的还是
    “报错的是myCommand.Fill(ds, "person");”这句话