0
votes

ERROR [42000] [MySQL][ODBC 5.1 Driver][mysqld-5.5.9-log]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 '​CALL spCreateTrade (27756,'27751','820','1','126','TRADE','Approved')' at line 1

This query works perfectly fine in an editor like MySQL workbench. I've used the same SQL user. I cannot for the life of me figure out why this doesn't work.

        parameters.Add(new OdbcParameter("pEmployeeDB_ID", co.DB_ID));
        parameters.Add(new OdbcParameter("pOther_EmployeeDB_ID", EmployeeDB_ID.ToString()));
        parameters.Add(new OdbcParameter("pCO_ID", CO_ID.ToString()));
        parameters.Add(new OdbcParameter("pDPID", co.Department_Position_ID.ToString()));            
        parameters.Add(new OdbcParameter("pCompleted_By", Completed_By.ToString()));
        parameters.Add(new OdbcParameter("pAction_type", "TRADE"));
        parameters.Add(new OdbcParameter("sStatus", "Approved"));

        string sql = "​CALL spCreateTrade (?,?,?,?,?,?,?)";


        DataSet retVal = new DataSet();


        if (connString != null)
        {
            using (OdbcConnection connection = new OdbcConnection(connString))
            {
                //Open it
                connection.Open();
                //Create the command
                OdbcCommand command = new OdbcCommand(sql, connection);
                command.CommandType = cmdType;
                if (parameters != null)
                {
                    foreach (OdbcParameter p in parameters)
                    {
                        command.Parameters.Add(p);
                    }
                }

                command.ExecuteNonQuery();


                //Close the connection.
                connection.Close();
            }
        }
1

1 Answers

0
votes

Enclose the SQL in brackets:

string sql = "{ ​CALL spCreateTrade (?,?,?,?,?,?,?) }";