我有这个代码:
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();}
Exception : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''@Qt'=0; SELECT * ...
最佳答案
联盟应写同名或别名 所以,你可以修改两个select语句中的别名相同
关于c# - sqlCommand 和 "SET @q:"变量 C# 异常?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26236954/