这是我的代码:
using (MySql.Data.MySqlClient.MySqlConnection cn = new
MySql.Data.MySqlClient.MySqlConnection(
Properties.Settings.Default.CONNNConnectionString))
{
cn.Open();
MySql.Data.MySqlClient.MySqlCommand cm = new
MySql.Data.MySqlClient.MySqlCommand();
cm.CommandType = CommandType.Text;
cm.Connection = cn;
cm.CommandText="CREATE PROCEDURE `GetMovement`(RefArtt vARCHAR(20),idos INTEGER) "+
"BEGIN "+
"SET @Qt=0; "SELECT * ,@Qt:=@Qt+qteliv-qtesor as stock FROM tableInOut;"+
"End";
cm.ExecuteNonQuery();}
异常:您的SQL语法有错误;检查与您的MySQL服务器版本相对应的手册,以在``@ Qt'= 0''附近使用正确的语法;选择 * ...
最佳答案
我不明白您的查询100%:
SELECT * ,@Qt:=@Qt+qteliv-qtesor as stock FROM tableInOut;
如果可以解释,以便我在需要时调整代码,但是这里有一个示例:
using (MySql.Data.MySqlClient.MySqlConnection cn = new
MySql.Data.MySqlClient.MySqlConnection(
Properties.Settings.Default.CONNNConnectionString))
{
cn.Open();
MySql.Data.MySqlClient.MySqlCommand cm = new
MySql.Data.MySqlClient.MySqlCommand();
cm.CommandType = CommandType.Text;
cm.Connection = cn;
cm.CommandText=@"
DELIMITER //
CREATE PROCEDURE GetMovement(IN RefArtt VARCHAR(20), IN idos INTEGER)
BEGIN
SELECT *
FROM tableInOut
WHERE ref = RefArtt AND id = idos;
END //
DELIMITER ;
";
cm.ExecuteNonQuery();
}
关于c# - 创建具有参数的程序?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/26382277/