将参数传递给MysqldataReder

时间:2014-02-03 08:03:06

标签: c# mysql asp.net

SELECT machine_id,operator_id,member_id,card_id,name,paid_amount,due_amount,paid_date,phone_number,@curRow := @curRow + 1 AS row_number
FROM transaction JOIN (SELECT @curRow := 0) r
where card_id=@card
order by Row_number desc limit 3 ;

当我在Mysql工作台中运行时,我的查询给出了正确的结果。但是在程序中它给出了错误

  

参数' @ curRow'必须定义。

String query3 = "SELECT machine_id,operator_id,member_id,card_id,name,paid_amount,due_amount,paid_date,phone_number ,@curRow := @curRow + 1 AS row_number FROM transaction JOIN  (SELECT @curRow := 0) r where card_id=@card order by Row_number desc limit 3 ";

MySqlCommand command3 = new MySqlCommand(query3, con);
command3.Parameters.AddWithValue("@card", cardid);
using (MySqlDataReader rdr3 = command3.ExecuteReader())

0 个答案:

没有答案