3 Replies - 411 Views - Last Post: 11 August 2011 - 07:42 PM Rate Topic: -----

#1 hellhound  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 109
  • Joined: 07-March 09

Database update syntax error

Posted 11 August 2011 - 06:29 PM

Good afternoon,

I have been working on a project for awhile now and have gotten to a point where I cannot update the database after changing it. below is a sample of my code incase anyone can see where I have gone wrong.
I have declared the database connection in another part of the program.

Dim MaxRows As Integer
            Dim Sql As String
            Dim da As OleDb.OleDbDataAdapter
            Dim ds As New DataSet
            Sql = "SELECT * FROM cardatabase"
            da = New OleDb.OleDbDataAdapter(Sql, con)
            Dim cb As New OleDb.OleDbCommandBuilder(da)
            da.Fill(ds, "cardatabase")
            MaxRows = ds.Tables("cardatabase").Rows.Count
            For inc As Integer = 0 To MaxRows - 1
                If LicencePLate.Text = ds.Tables("cardatabase").Rows(inc).Item(1) Then
                    ds.Tables("cardatabase").Rows(inc).Item(4) = "Out"
                    da.Update(ds, "cardatabase")
                End If

            Next


the error that I am getting is a syntax error on the da.Update function.

thanks

Is This A Good Question/Topic? 0
  • +

Replies To: Database update syntax error

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8937
  • View blog
  • Posts: 33,467
  • Joined: 12-June 08

Re: Database update syntax error

Posted 11 August 2011 - 07:14 PM

*WHAT* error would be helpful. Did you instantiate a command object for the update?
Was This Post Helpful? 0
  • +
  • -

#3 hellhound  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 109
  • Joined: 07-March 09

Re: Database update syntax error

Posted 11 August 2011 - 07:17 PM

sorry the error just states there is a syntax error with the update command.

Um on the command object I thought that that was what the
Dim cb As New OleDb.OleDbCommandBuilder(da)

is for? please correct me if I am wrong.

This post has been edited by hellhound: 11 August 2011 - 07:18 PM

Was This Post Helpful? 0
  • +
  • -

#4 Elda  Icon User is offline

  • D.I.C Regular

Reputation: 31
  • View blog
  • Posts: 314
  • Joined: 30-December 10

Re: Database update syntax error

Posted 11 August 2011 - 07:42 PM

sql = "Update tableName Set Lastname=@Lastname where...... 

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1