Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
when i tried this code it is giving syntax error in update statement please help me solve this error

What I have tried:

  Public Sub ud()
        Try
            Dim oledbcommand As String = "UPDATE Personal  SET EmpID=? , EmpName=? , CATIAV5=? , UGNX=? , FIDES=? , PROE=? , SOLIDWORKS=? , SOLIDEDGE=? , ROBCAD=? , PROCESSSIMULATE=? , DECIMA=? , IGRIP=? , QUEST=? , EMPLANT=? , PROCESSDESIGNER=? , AutoCAD=? , FACTORYCAD=? , MICROSTATION=? , VBA=? , C/C++ =? , VBdotNET=? "
            Dim com As New OleDb.OleDbCommand(oledbcommand, con)
            com.Connection = con
            com.Parameters.AddWithValue("?", cboxempid.Text)
            com.Parameters.AddWithValue("?", cboxfname.Text)
            com.Parameters.AddWithValue("?", cboxcatia.Text)
            com.Parameters.AddWithValue("?", cboxugnx.Text)
            com.Parameters.AddWithValue("?", cboxfides.Text)
            com.Parameters.AddWithValue("?", cboxproe.Text)
            com.Parameters.AddWithValue("?", cboxsworks.Text)
            com.Parameters.AddWithValue("?", cboxsedge.Text)
            com.Parameters.AddWithValue("?", cboxrcad.Text)
            com.Parameters.AddWithValue("?", cboxpsimulate.Text)
            com.Parameters.AddWithValue("?", cboxdecima.Text)
            com.Parameters.AddWithValue("?", cboxigrip.Text)
            com.Parameters.AddWithValue("?", cboxquest.Text)
            com.Parameters.AddWithValue("?", cboxem.Text)
            com.Parameters.AddWithValue("?", cboxpdesigner.Text)
            com.Parameters.AddWithValue("?", cboxauto.Text)
            com.Parameters.AddWithValue("?", cboxfcad.Text)
            com.Parameters.AddWithValue("?", cboxmsta.Text)
            com.Parameters.AddWithValue("?", cboxvba.Text)
            com.Parameters.AddWithValue("?", cboxc.Text)
            com.Parameters.AddWithValue("?", cboxdotnet.Text)
            For Each parameter As OleDb.OleDbParameter In com.Parameters
                If parameter.Value Is Nothing Then
                    parameter.Value = DBNull.Value

                End If
            Next
            com.ExecuteNonQuery()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
        con.Close()
        con.Dispose()
    End Sub
End Class
Posted
Updated 19-Mar-17 21:13pm

1 solution

like this

Dim oledbcommand As String = "UPDATE Personal  SET EmpID=@EmpID , EmpName=@EmpName , CATIAV5=@CATIAV5 , ......."
            Dim com As New OleDb.OleDbCommand(oledbcommand, con)
            com.Connection = con
            com.Parameters.AddWithValue("@EmpID", cboxempid.Text)
            com.Parameters.AddWithValue("@EmpName", cboxfname.Text)
            com.Parameters.AddWithValue("@CATIAV5", cboxcatia.Text)
            .
            .
            .


refer vb sql parameter[^]
 
Share this answer
 
v2

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