943,625 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Marked Solved
  • Views: 1844
  • VB.NET RSS
Jun 12th, 2008
0

Syntax error on update database code

Expand Post »
Hello Everyone,

I am very new to VB and currently using VB Express 2008 to create a simple program. However, I am running into a syntax error on my update code. I have done some research on the web but cannot find a common thread. I am hoping some of the experts could take a look and help me understand where I am going wrong with the syntax.

Code:

Public Shared Function UpdateAcctUsers(ByVal oldusermaint As UserMaint, ByVal newusermaint As UserMaint) As Boolean
        Dim connection As OleDbConnection = FINDB.GetConnection()
        Dim updateStatement As String _
            = "UPDATE tblValidUsers SET " _
            & "IST = @NewIST, " _
            & "BS = @NewBS, " _
            & "CIS = @NewCIS, " _
            & "CBS = @NewCBS, " _
            & "LCIS = @NewLCIS, " _
            & "LCBS = @NewLCBS, " _
            & "RF = @NewRF, " _
            & "CF = @NewCF, " _
            & "FEAM = @NewFEAM, " _
            & "IC = @NewIC, " _
            & "STD = @NewSTD, " _
            & "PF = @NewPF, " _
            & "CS = @NewCS, " _
            & "WHERE fldUser = @OldfldUser " _
            & "AND IST = @OldIST " _
            & "AND BS = @OldBS " _
            & "AND CIS = @OldCIS " _
            & "AND CBS = @OldCBS " _
            & "AND LCIS = @OldLCIS " _
            & "AND LCBS = @OldLCBS " _
            & "AND RF = @OldRF " _
            & "AND CF = @OldCF " _
            & "AND FEAM = @OldFEAM " _
            & "AND IC = @OldIC " _
            & "AND STD = @OldSTD " _
            & "AND PF = @OldPF " _
            & "AND CS = @OldCS "
        Dim updateCommand As New OleDbCommand(updateStatement, connection)
        updateCommand.Parameters.AddWithValue("@NewIST", newusermaint.IST)
        updateCommand.Parameters.AddWithValue("@NewBS", newusermaint.BS)
        updateCommand.Parameters.AddWithValue("@NewCIS", newusermaint.CIS)
        updateCommand.Parameters.AddWithValue("@NewCBS", newusermaint.CBS)
        updateCommand.Parameters.AddWithValue("@NewLCIS", newusermaint.LCIS)
        updateCommand.Parameters.AddWithValue("@NewLCBS", newusermaint.LCBS)
        updateCommand.Parameters.AddWithValue("@NewRF", newusermaint.RF)
        updateCommand.Parameters.AddWithValue("@NewCF", newusermaint.CF)
        updateCommand.Parameters.AddWithValue("@NewFEAM", newusermaint.FEAM)
        updateCommand.Parameters.AddWithValue("@NewIC", newusermaint.IC)
        updateCommand.Parameters.AddWithValue("@NewSTD", newusermaint.STD)
        updateCommand.Parameters.AddWithValue("@NewPF", newusermaint.PF)
        updateCommand.Parameters.AddWithValue("@NewCS", newusermaint.CS)
        updateCommand.Parameters.AddWithValue("@OldfldUser", oldusermaint.fldUser)
        updateCommand.Parameters.AddWithValue("@OldIST", oldusermaint.IST)
        updateCommand.Parameters.AddWithValue("@OldBS", oldusermaint.BS)
        updateCommand.Parameters.AddWithValue("@OldCIS", oldusermaint.CIS)
        updateCommand.Parameters.AddWithValue("@OldCBS", oldusermaint.CBS)
        updateCommand.Parameters.AddWithValue("@OldLCIS", oldusermaint.LCIS)
        updateCommand.Parameters.AddWithValue("@OldLCBS", oldusermaint.LCBS)
        updateCommand.Parameters.AddWithValue("@OldRF", oldusermaint.RF)
        updateCommand.Parameters.AddWithValue("@OldCF", oldusermaint.CF)
        updateCommand.Parameters.AddWithValue("@OldFEAM", oldusermaint.FEAM)
        updateCommand.Parameters.AddWithValue("@OldIC", oldusermaint.IC)
        updateCommand.Parameters.AddWithValue("@OldSTD", oldusermaint.STD)
        updateCommand.Parameters.AddWithValue("@OldPF", oldusermaint.PF)
        updateCommand.Parameters.AddWithValue("@OldCS", oldusermaint.CS)
        Try
            connection.Open()
            Dim count As Integer = updateCommand.ExecuteNonQuery
            If count > 0 Then
                Return True
            Else
                Return False
            End If
        Catch ex As Exception
            Throw ex
        Finally
            connection.Close()
        End Try
    End Function

Thanks in advance for your help!

Brad
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
witternb is offline Offline
4 posts
since Jun 2008
Jun 12th, 2008
0

Re: Syntax error on update database code

one problem is the comma before the WHERE.

Replace
VB.NET Syntax (Toggle Plain Text)
  1. & "CS = @NewCS, " _
  2. & "WHERE fldUser = @OldfldUser " _
by
VB.NET Syntax (Toggle Plain Text)
  1. & "CS = @NewCS " _
  2. & "WHERE fldUser = @OldfldUser " _
If more syntax errors please post back
Reputation Points: 25
Solved Threads: 5
Newbie Poster
dadelsen is offline Offline
22 posts
since Jun 2007
Jun 12th, 2008
0

Re: Syntax error on update database code

That was it...Thank you very much for your assistance!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
witternb is offline Offline
4 posts
since Jun 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: byref in vb.net
Next Thread in VB.NET Forum Timeline: Problem in retrieving data using data binding





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC