I am developing a sequence in MySQL & VB.NET in which, when deleting a record, the number that identifies it, is deleted and put a sequence of 1 to 'n', the sequence is as follows.
this is the instruccion for MySQL.
SET @rownum=0;
UPDATE id_line t, (SELECT @rownum:=@rownum+1 rownum, id_line.* FROM id_line WHERE id_line.line_name=59999 and id_line.line_no<>0) r
SET t.line_no = r.rownum
WHERE (t.id_line_b = r.id_line_b)
in VB.net I use this
cmdB = New MySqlCommand("SET @rownum=0 UPDATE id_line t, (SELECT @rownum=:@rownum+1 rownum, id_line.* FROM id_line WHERE id_line.line_name='" & TextBox1.Text & "' and id_line.line_no<>0) r ) SET t.line_no = r.rownum WHERE(t.id_line_b = r.id_line_b)", conn)
but VB sends this error
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 'UPDATE id_line t, (SELECT @rownum=:@rownum+1 rownum, id_line.* FROM id_lin' at line 1
Could you help me please in this error?
Updated 1: This is my string connection.
Public conString As String = "Data Source=server_one;port=3306;Initial Catalog=test_db;User Id=root;password=root;Allow User Variables=True"
SET @rownum=0;but it doesn't appear in the string in the VB.NET code.