Syntax error in UPDATE statement
Hi,
I seem to be getting the error "Syntax error in UPDATE statement." when attempting to update my database through visual studio 2008, using forms.
Here is the code for the connection:
Private Sub btnLoadDB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoadDB.Click
Provider = "PROVIDER=MICROSOFT.ACE.OLEDB.12.0;"
Source = "Data Source = F:\My Documents\Computing\COMP4\COMP4 CW\WND.accdb"
connection.ConnectionString = Provider & Source
connection.Open()
sqlCode = "SELECT * FROM Newspapers"
dAdapter = New OleDb.OleDbDataAdapter(sqlCode, connection)
dAdapter.Fill(dSet, "Newspapers")
MsgBox("Database Loaded.", MsgBoxStyle.Information)
connection.Close()
maxRows = dSet.Tables("Newspapers").Rows.Count
incr = -1
End Sub
The code for the update button on my form:
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
Dim cBuilder As New OleDb.OleDbCommandBuilder(dAdapter)
dSet.Tables("Newspapers").Rows(incr).Item(0) = txtPMID.Text
dSet.Tables("Newspapers").Rows(incr).Item(1) = txtPMName.Text
dSet.Tables("Newspapers").Rows(incr).Item(2) = txtPMPrice.Text
dAdapter.Update(dSet, "Newspapers")
MsgBox("The record was successfully updated", MsgBoxStyle.Information)
End Sub
Any help would be greatly appreciated.
Thanks
Collin
(p.s. I am using the following tutorial:
http://www.homeandlearn.co.uk/NET/nets12p9.html )
Related Article: UPDATE STATEMENT ERROR.vb.net
is a solved VB.NET discussion thread by timothy0726 that has 11 replies, was last updated 1 year ago and has been tagged with the keywords: error, statement, update, vb.net.
collin_ola
Junior Poster in Training
55 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
What is "cBuilder" doing for you?
thines01
Postaholic
2,433 posts since Oct 2009
Reputation Points: 447
Solved Threads: 408
Skill Endorsements: 7
What is "cBuilder" doing for you?
The cBuilder is the command builder; it builds the sql strings.
collin_ola
Junior Poster in Training
55 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
thines01
Postaholic
2,433 posts since Oct 2009
Reputation Points: 447
Solved Threads: 408
Skill Endorsements: 7
When is it being used?
dAdapter.Update(dSet, "Newspapers")
In the above line. I'm sorry if I'm not being very clear, I'm a student, and I don't have the best teachers :(
collin_ola
Junior Poster in Training
55 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
Do you need to call
cBuilder.GetUpdateCommand()
right before calling the Update on the Adapter?
thines01
Postaholic
2,433 posts since Oct 2009
Reputation Points: 447
Solved Threads: 408
Skill Endorsements: 7
Do you need to call
cBuilder.GetUpdateCommand()
right before calling the Update on the Adapter?
I don't think I need to, no..
collin_ola
Junior Poster in Training
55 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0