string sql = @"UPDATE ivendas SET nritem=(@rank:=(@rank+1)) where id_venda = 20";
try
{
MySQLBase basemysql = new MySQLBase();
MySqlCommand cmd = basemysql.connection.CreateCommand();
cmd.CommandText = sql;
cmd.CommandTimeout = 1000;
cmd.Parameters.AddWithValue("@rank",0);
cmd.ExecuteNonQuery();
basemysql.Closer();
}
catch (Exception erro)
{
string teste = erro.ToString();
Console.WriteLine(teste);
}
Remembering that my RANK is my accountant. So a parameter or variable.
My error is the one from here - >
"MySql.Data.MySqlClient.MySqlException (0x80004005): 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 ': = (0 + 1)) where sales_id = 20 'at line 1 \ r \ n MySql.Data.MySqlClient.MySqlStream.ReadPacket () \ r \ n MySql.Data.MySqlClient.NativeDriver.GetResult (Int32 & affectedRow, Int64 & insertedId) \ r \ n MySql.Data.MySqlClient.Driver.GetResult (Int32 statementId, Int32 & affectedRows, Int64 & insertedId) \ r \ n MySql.Data.MySqlClient.Driver.NextResult (Int32 statementId, Boolean force) \ r \ n MySql.Data.MySqlClient.MySqlDataReader.NextResult () \ r \ n MySql.Data.MySqlClient.MySqlCommand.ExecuteReader (CommandBehavior behavior) \ r \ n MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery () \ r \ n Restaurante.Ivendas.OrganizarItensdaVenda (String idvenda) "
My bank
nritem | id_venda
2 | 20
3 | 20
4 | 20
I need you to look like this:
nritem | id_venda
1 | 20
2 | 20
3 | 20