Click here to Skip to main content
15,885,944 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
MysqlConn = New MySqlConnection
MysqlConn.ConnectionString = "server=localhost;userid=root;database=stock_sales_system"
Command = New MySqlCommand("UPDATE supplier SET SupplierName=@SupplierName, Address=@Address, Telephone=@Telephone, ContactPerson=@ContactPerson, StartDate=@StartDate, Description=@Description, WHERE SupplierName=@Name", MysqlConn)

Command.Parameters.Add("@SupplierName", MySqlDbType.VarChar).Value = txtSupplierName.Text
Command.Parameters.Add("@Address", MySqlDbType.VarChar).Value = txtAddress.Text
Command.Parameters.Add("@Telephone", MySqlDbType.VarChar).Value = txtTelephone.Text
Command.Parameters.Add("@ContactPerson", MySqlDbType.VarChar).Value = txtContactPerson.Text
Command.Parameters.Add("@StartDate", MySqlDbType.DateTime).Value = dtpDate.Value
Command.Parameters.Add("@Description", MySqlDbType.VarChar).Value = txtDescription.Text
Command.Parameters.Add("@Name", MySqlDbType.VarChar).Value = frmManageSuppliers.SupplierTableAdapter.GetSupplierName(frmViewSupplier.lblSupplierName.Text)

Try
MysqlConn.Open()
Command.ExecuteNonQuery()
MessageBox.Show("Supplier information updated.", "Data updated",
MessageBoxButtons.OK,
MessageBoxIcon.Information)
MysqlConn.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
MysqlConn.Dispose()
End Try

What I have tried:

i get this exception: "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 'WHERE SupplierName='Lordos'' at line 1
Posted
Updated 24-Apr-20 4:34am
Comments
F-ES Sitecore 24-Apr-20 8:29am    
This is a guess but you have a comma before the WHERE, it might be as simple as removing it

Description=@Description, WHERE SupplierName=@Name

to

Description=@Description WHERE SupplierName=@Name
phil.o 24-Apr-20 8:41am    
This is basically the correct answer :)
Andreas322 24-Apr-20 8:57am    
huh i did not notice that comma.. thank you very much i was struggling to find the mistake
ZurdoDev 24-Apr-20 9:38am    
For future reference, the error told you exactly where the problem was.
ZurdoDev 24-Apr-20 9:38am    
Post as solution please.

1 solution

This is a guess but you have a comma before the WHERE, it might be as simple as removing it

Description=@Description, WHERE SupplierName=@Name


to

Description=@Description WHERE SupplierName=@Name
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900