Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...