3
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 my RANK and my counter. Therefore a parameter or variable.
My mistake and this one ->
"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 id_venda = 20' at line 1 r n at Mysql.Data.Mysqlclient.MySqlStream.Readpacket() r n in Mysql.Data.Mysqlclient.NativeDriver.Getresult(Int32& affectedRow, Int64& insertedId) r n in Mysql.Data.Mysqlclient.Driver.Getresult(Int32 statementId, Int32& affectedRows, Int64& insertedId) r n on Mysql.Data.Mysqlclient.Driver.Nextresult(Int32 statementId, Boolean force r n in Mysql.Data.Mysqlclient.MySqlDataReader.Nextresult() r n in Mysql.Data.Mysqlclient.MySqlCommand.Executereader(Commandbehavior behavior) n in Mysql.Data.Mysqlclient.MySqlCommand.Executenonquery() r n on Restaurante.Ivendas.Organizaritensdavenda(String idvenda)"
My bank
nritem | id_venda
2 | 20
3 | 20
4 | 20
I need you to stay like this:
nritem | id_venda
1 | 20
2 | 20
3 | 20
the value of
nritem
will be equal to the valueparametro := parametro + 1
? what do you want to do with it ?– Rovann Linhalis
wouldn’t just be:
nritem= @rank + 1
– Rovann Linhalis
I put it in the body of the question.
– Fabio C
see if my answer helps
– Rovann Linhalis