想实现.连接数据库,在DataGrid中显示出来的功能.
    不知道错那了..主要程序..
this.dbConn.ConnectionString = "workstation id=TOTTI;packet size=4096;user id=sa;data source=TOTTI;persist securi" +"ty info=False;initial catalog=Tour DataBase";
private void sureButton_Click(object sender, System.EventArgs e)
{
dbConn.Open();//打开数据库连接
this.dbComm=new System.Data.SqlClient.SqlCommand(mySQL,dbConn);
this.dbAdap  = new System.Data.SqlClient.SqlDataAdapter();
this.dbDS = new System.Data.DataSet();
dbAdap.SelectCommand=dbComm;
dbDS.Clear();
dbAdap.Fill(dbDS);
}

解决方案 »

  1.   

    修改一下
    this.dbConn.ConnectionString = "Data Source=TOTTI;User ID=sa;Password=;Initial Catalog=Tour DataBase";
    private void sureButton_Click(object sender, System.EventArgs e)
    {
    dbConn.Open();//打开数据库连接
    this.dbAdap  = new System.Data.SqlClient.SqlDataAdapter(mySQL,dbConn);
    this.dbDS = new System.Data.DataSet();
    dbAdap.Fill(dbDS);
    }
      

  2.   

    还有dbConn实例化了没有
    this.dbConn=new System.Data.SqlClient.SqlConnection();
      

  3.   

    dbConn=new System.Data.SqlClient.SqlConnection();
      

  4.   

    你的ConnectionString错了要么使用系统认证,要么使用SQL Server认证,两者不能同时使用。
      

  5.   

    大部分代码 是STUDIO 写的,想手写一部分,但是功能实现不了...
      

  6.   

    现在 数据库连接估计是没什么问题..
       但是DATASET的数据 在DATAGRID中显示不出来...
      

  7.   

    提供数据源和数据绑定
    DataGridCustomers.DataSource = dbDS ;
    DataGridCustomers.DataBind();
      

  8.   

    DataBind();
    windows 窗体中,没有这个方法撒........
      

  9.   

    问题解决了
       SetDataBinding();