mycommand.CommandText = sql;
换成mycommand.CommandText="select * from 个人信息"

解决方案 »

  1.   

    mycommand.CommandText = sql;
    sql未赋值吧
      

  2.   


    using (SqlConnection myconnection = new SqlConnection(connection))
    {
      SqlCommand mycommand = myconnection.CreateCommand();
      mycommand.CommandType = CommandType.Text;
      mycommand.CommandText = sql;    
      myconnection.Open();
      SqlDataAdapter mydataadapter = new SqlDataAdapter(mycommand);
      DataSet mydataset = new DataSet();
      mydataadapter.Fill(mydataset, "个人信息");
      BindingSource bindingsource1 = new BindingSource();
      bindingsource1.DataSource = mydataset;
      bindingsource1.DataMember = "个人信息";
      myconnection.Close();
    }看看SqlDataAdapter,SqlCommand 的构造函数吧。 
      

  3.   

      sql 我定义成了 public 的   已经赋过值的 ~~~~
      

  4.   

    DataSet ds=new DataSet ();
    using (SqlConnection conn =  
      new SqlConnection(TSConfig.GetConnectionString()))  
      {  
    SqlCommand sqlCmd = new SqlCommand(strSelect, conn);  
    cmd.CommandType=CommandType.Text ;
    SqlDataAdapter sda=new SqlDataAdapter();
    sda.SelectCommand=cmd;
    try
    {
    sda.Fill (ds);
    }
    catch(Exception e)
    {
      throw e;
    }
    }
    贴出代码
      

  5.   

    SqlDataAdapter mydataadapter = new SqlDataAdapter(mycommand);
    你看下SqlDataAdapter()有没有参数