.net调用mysql存储过程

shuining1211 2007-12-14 01:14:10
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"];

}
为什么上面这个程序执行会出错?
...全文
154 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
dany_zj 2007-12-22
  • 打赏
  • 举报
回复
sda.SelectCommand.CommandType = CommandType.StoredProcedure;

默认情况下会以sql文本处理

call sp_Select();
shuining1211 2007-12-14
  • 打赏
  • 举报
回复
top
shuining1211 2007-12-14
  • 打赏
  • 举报
回复
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

在网上搜不到,谢谢!
懒得去死 2007-12-14
  • 打赏
  • 举报
回复
错误信息呢?

56,677

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧