Results 1 to 3 of 3

Thread: [RESOLVED] Syntax error in UPDATE statement.

  1. #1

    Thread Starter
    Lively Member viper5646's Avatar
    Join Date
    Feb 2009
    Location
    kitchener Ontario
    Posts
    90

    Resolved [RESOLVED] Syntax error in UPDATE statement.

    Hi ALL

    I have an UPDATE query which gives me a syntax error in the Cmd. .ExecuteNonQuery() line.
    I Have checked that the connection, table names, and data types are correct.
    I Just can't put my finger on whats causing the error.
    Hope some one can help me.
    Here is the code
    Thank you.

    Code:
    Public Class EditServices
        Private ServiceId As Integer
        Private quantidade As Integer
    
        Public Property SetID As Integer
            Get
                Return ServiceId
            End Get
            Set(value As Integer)
                ServiceId = value
            End Set
        End Property
        Public Property Qunty As Integer
            Get
                Return quantidade
            End Get
            Set(value As Integer)
                quantidade = value
            End Set
        End Property
    
      
    
        Public Sub Updateservices(ByVal taxa As Decimal, ByVal subtotal As Decimal)
            Try
    
                Dim query As String = "UPDATE JobEntries_tbl SET [Itemquantity]=@qnty, [Taxes]=@taxs, [SubTotal]=@subTotl, WHERE [JobEntryID]=@ID"
                Dim DBCon As New Connection
                DBCon.FilePath = "C:\CFI\filepath.txt"
                DBCon.connect()
                DBCon.con.Open()
                Dim cmd As New OleDb.OleDbCommand(query, DBCon.con)
                With cmd
                    .CommandType = CommandType.Text
                    .CommandText = query
                    .Parameters.AddWithValue("@qnty", quantidade)
                    .Parameters.AddWithValue("@taxs", taxa)
                    .Parameters.AddWithValue("@subTotl", subtotal)
                    .Parameters.AddWithValue("@ID", ServiceId)
                    .ExecuteNonQuery()
                End With
                DBCon.con.Close()
    
            Catch ex As Exception
                MsgBox("EditServices_Updateservices: " & ex.Message)
            End Try
        End Sub
    End Class

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Syntax error in UPDATE statement.

    You have an extra comma in there.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Lively Member viper5646's Avatar
    Join Date
    Feb 2009
    Location
    kitchener Ontario
    Posts
    90

    Re: Syntax error in UPDATE statement.

    Wow:

    Thanks John for your reply.
    I Should look more carefully next time.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width