| | |
Syntax error on update database code
Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Jun 2008
Posts: 4
Reputation:
Solved Threads: 0
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:
Thanks in advance for your help!
Brad
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 FunctionThanks in advance for your help!
Brad
•
•
Join Date: Jun 2007
Posts: 22
Reputation:
Solved Threads: 5
one problem is the comma before the WHERE.
Replace
by
If more syntax errors please post back
Replace
VB.NET Syntax (Toggle Plain Text)
& "CS = @NewCS, " _ & "WHERE fldUser = @OldfldUser " _
VB.NET Syntax (Toggle Plain Text)
& "CS = @NewCS " _ & "WHERE fldUser = @OldfldUser " _
![]() |
Similar Threads
- MySQL syntax error 1064 (MySQL)
- Syntax error in INSERT INTO statement (Java)
- UPDATE query problem (ASP.NET)
- Problems on Insert and Update Statement (C#)
- Problems on Insert and Update (C#)
- Insert and Update Errors (C#)
- how to validate text file, loading into listbox (Visual Basic 4 / 5 / 6)
- Error connecting to database (ASP.NET)
Other Threads in the VB.NET Forum
- Previous Thread: byref in vb.net
- Next Thread: Problem in retrieving data using data binding
| Thread Tools | Search this Thread |
.net 30minutes 2005 2008 access account arithmetic array arrays basic binary bing button buttons c# center check checkbox code combobox component connectionstring convert crystalreport data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dropdownlist excel file-dialog folder ftp generatetags google gridview hardcopy image images inline insert intel internet listview mobile monitor ms net networking output passingparameters peertopeervideostreaming picturebox picturebox1 plugin port print printing problem problemwithinstallation project reports" save searchbox searchvb.net select serial server soap sorting table tcp text textbox timer toolbox trim update updown user usercontrol vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio2008 web wpf





