[英]Inserting multiple records into MySQL using MySqlCommand in one query C# (MySQLConnector) & command Parameters for escaping quotes
[英]Parameter escaping in MySQL using C#
我在C#中有一个这样的存储过程创建代码。
string query="CREATE PROCEDURE `MyProc`(IN `searchText` text, IN `iterationsCount` INT, IN `filterName` char(30))
BEGIN
DECLARE i INT;
SET i = 1;
SET @sSelectBilling = 'count(distinct t.BillingID) from Billing t';
.....
.....
END"
当我尝试使用MySQLCommand.ExecuteNonQuery()通过C#创建此sp时; 我收到错误信息,必须定义参数'@sSelectBilling'。 如何解决呢?
尝试这个
CREATE PROCEDURE `MyProc` (
`searchText` text,
`iterationsCount` INT,
`filterName` char(30) )
BEGIN
DECLARE i INT;
DECLARE @sSelectBilling INT; // define your variable here.
SET i = 1;
SET @sSelectBilling = (count(distinct t.BillingID) from Billing t);//use () instead of quotes.
弄清楚自己。 我需要添加Allow User Variables = true; 在连接字符串中。 下一篇文章帮助我弄清楚了http://markcordell.blogspot.com/2008/12/calling-mysql-stored-procedures-from-c.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.