1

i have this code:

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 * ...

1
  • have you declared @Qt? Commented Oct 7, 2014 at 13:22

1 Answer 1

0

Union should to write the same names or alias So, you can modify the alias to be the same in two select statement

Sign up to request clarification or add additional context in comments.

1 Comment

i added the query as procedure and then call it from c# code it work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.