public DataTable selectAllPerson()
{
string constr = "UserId=root;Host=localhost;Database=test;password=1234";
MySqlConnection conn = new MySqlConnection(constr);
MySqlDataAdapter sda=new MySqlDataAdapter();
sda.SelectCommand =new MySqlCommand("sp_Select(存储过程名称)",conn);
DataSet ds = new DataSet();
sda.Fill(ds,"T_User");
return ds.Tables["T_User"]; }
public DataTable selectAllPerson()
{
string constr = "UserId=root;Host=localhost;Database=test;password=1234";
MySqlConnection conn = new MySqlConnection(constr);
MySqlDataAdapter sda=new MySqlDataAdapter();
sda.SelectCommand =new MySqlCommand("select * fromT_User",conn);
DataSet ds = new DataSet();
sda.Fill(ds,"T_User");
return ds.Tables["T_User"]; }
为什么上面这个程序执行会出错?

解决方案 »

  1.   

    MySql.Data.MySqlClient.MySqlException: #42000You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'sp_Select' at line 1在网上搜不到,谢谢!
      

  2.   

    sda.SelectCommand.CommandType = CommandType.StoredProcedure;默认情况下会以sql文本处理call sp_Select();