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.OL EDB.4.0;Da ta 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(adapte r)
adapter.Fill(dsLinks, "Link")
With dsLinks.Tables("Link")
For rowcount = 0 To .Rows.Count - 1
.Rows(rowcount).Item("IsIn dexed") = "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?
Dim connectionString As String = "Provider=Microsoft.Jet.OL
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(adapte
adapter.Fill(dsLinks, "Link")
With dsLinks.Tables("Link")
For rowcount = 0 To .Rows.Count - 1
.Rows(rowcount).Item("IsIn
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ie:
adapter.SelectCommand.Para
adapter.fill(dataset,table