1、Select * From chuang_AgentInfo Where UserName='成都'  --在MySql工具里面查询有记录2、以下代码查询上面语句,没有记录table.row.count为0
MySqlCommand thisCommand = new MySqlCommand();
thisCommand.CommandTimeout = 0; // make sure connection is open
MySqlConnection con = new MySqlConnection(vStrConn);
try
{
    con.Open();
    thisCommand.Connection = con;
thisCommand.CommandText = SQL;     MySqlDataAdapter thisAdapter = new MySqlDataAdapter();
    thisAdapter.SelectCommand = thisCommand;
    DataTable table = new DataTable();
    thisAdapter.Fill(table);
    return table;
}3、以上代码查询 Select * From chuang_AgentInfo 有记录,可以查到。

解决方案 »

  1.   


      SqlConnection conn = new SqlConnection(str);//str连接字符串
      SqlDataAdapter sda = new SqlDataAdapter(selectStr, conn);//selectStr查询字符串
      DataTable dt = new DataTable();
      sda.Fill(dt);
      return dt;我平时是这样用的
      

  2.   

    楼主用的是mysql,
    仔细看一下没什么不妥
      

  3.   

    至于连接字符串,可以参看
    http://www.connectionstrings.com/mysql