manuelpeh Posted February 19, 2010 Posted February 19, 2010 im trying to make a method for update query, to receive parameters and values and process the update for all fields with values for each one, but it gives me an error: here is my code: Public Sub qUpdate(ByVal Table As String, ByVal Fields As String, ByVal Values As String, ByVal Condicion As String) Conexion.myCommand.Connection = conn Conexion.myCommand.CommandType = CommandType.Text Conexion.myCommand.CommandText = "Update " & Table & " set " & Fields & " = """ & Values & """ where " & Condicion & "" Call Connecta() myCommand.ExecuteNonQuery() Call Desconecta() End Sub i pass the parameters in this way: Fields = "Nombre, ApePat, ApeMat" Values = str_cliente.Nombre & "," & str_cliente.ApePat & "," & str_cliente.ApeMat then i call for qUpdate method and pass the parameteres avobe Call qUpdate("clientes", Fields, Values, "Id_Cliente=" & str_cliente.Id_Cliente) when i try to do the query it throws me an 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 ' ApePat, ApeMat = "manuel,manuel,manuel" where Id_Cliente=3' at line 1"} what should i do, i want to create an update method to be dynamic, so i can use it for any amount of fields and values for any table.. help me pls Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.