Link to home
Start Free TrialLog in
Avatar of johnalphaone
johnalphaone

asked on

Syntax Error on ADO.NET Update

Using VB.NET 2005, first attempt at updating a table using ADO.NET.  Here's the stripped down code:

        Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\LinkCheck\db.mdb"
        Dim sql As String
        Dim adapter As OleDbDataAdapter
        Dim cmdBuilder As OleDbCommandBuilder
        Dim dsLinks As New DataSet
        Dim rowcount As Integer

        sql = "SELECT * FROM [Link] WHERE [IncludeInSearch] = True"
        adapter = New OleDbDataAdapter(sql, connectionString)
        cmdBuilder = New OleDbCommandBuilder(adapter)
        adapter.Fill(dsLinks, "Link")

        With dsLinks.Tables("Link")
            For rowcount = 0 To .Rows.Count - 1
                .Rows(rowcount).Item("IsIndexed") = "yes"
                adapter.Update(dsLinks, "Link")
            Next
        End With

The Update fails with:-
"Syntax error (missing operator) in query expression '((ID = ?) AND ((? = 1 AND LinkingPage IS NULL) OR (LinkingPage = ?)) AND ((? = 1 AND TargetDomain IS NULL) OR (TargetDomain = ?)) AND ((? = 1 AND IsIndexed IS NULL) OR (IsIndexed = ?)) AND ((? = 1 AND IsCached IS NULL) OR (IsCached = ?)) AND ((? = 1 AND I'."


Any thoughts?
ASKER CERTIFIED SOLUTION
Avatar of johnalphaone
johnalphaone

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bill_PSC
Bill_PSC

I think you may have to add your select params on your dataadapter before the fill dataset command.

ie:

adapter.SelectCommand.Parameters("yourValue").Value =yourValue
adapter.fill(dataset,table)