1

This code works correctly and OK on the SQL Server.

Please convert this code to a MySQL.

Running on the MySQL gives the following error.

Error = You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '1=IdMax + 1 where TypeID>1' at line 1

Public Def_Command_SQL1 As SqlClient.SqlCommand
Def_Command_SQL1.CommandText = "UPDATE ID_Max1 SET IdMax = IdMax + 1 , @OutID = IdMax + 1 where TypeID>1"
Def_Command_SQL1.Parameters.Clear()   
Def_Command_SQL1.Parameters.Add(New SqlParameter("@OutID", SqlDbType.Int))=1
Def_Command_SQL1.Parameters("@OutID").Direction = ParameterDirection.Output
Def_Command_SQL1.ExecuteNonQuery()
IDMax_Update = Def_Command_SQL1.Parameters("@OutID").Value   

1 Answers1

0

So you can that what you want not in mysql.

You sql server query does essentially increasing IdMax with thenumber 1 and then transfer that increased number back to vb net.

That doesn't work in mysql.

And i really don't understand what you get when you see Update IdMax.

For that i must see the table, to fully understand what are trying to do..

What you can do is

First

SELECT MAX(IdMax) + 1 FROM ID_Max1 WHERE TypeID>1;

Get the highest number ,increase it and then store it in IDMax_Update

Here is explained how you store a result in a variavbkle

And then update the row or rows with

UPDATE ID_Max1 SET IdMax = IdMax WHERE TypeID>1;

You do 2 Querys and have the same result

nbk
  • 45,398
  • 8
  • 30
  • 47