Solved

Syntax Error on ADO.NET Update

Posted on 2006-06-18
3
278 Views
Last Modified: 2008-03-10
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?
0
Comment
Question by:johnalphaone
3 Comments
 

Accepted Solution

by:
johnalphaone earned 0 total points
ID: 16929110
Don't worry, solved it myself.

Added:
        cmdBuilder.QuotePrefix = "["
        cmdBuilder.QuoteSuffix = "]"

0
 
LVL 2

Expert Comment

by:Bill_PSC
ID: 16936260
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)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question