Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2009

    Unanswered: ADO.Net SQL query problem!

    Dear All,

    I have created a connection through OLEDB to a MS Access database and trying to run a query on it.

    rs.Open "SELECT * FROM myTable WHERE myVendor= '"& compName &"' AND myLATA= "&numbLATA&"" , conn

    Though the query is running fine, I am not able to leave the second field numbLATA blank, if i leave it blank it returns me an error:

    Syntax error (missing operator) in query expression 'myVendor= 'Atlantic Telecom' AND myLATA='.

    Please guide me such that I am able to run the query even when one of the fields in the WHERE clause is left blank and the SQL query would give a result.

    Many Thanks in advance.

  2. #2
    Join Date
    Mar 2003
    The Bottom of The Barrel
    Provided Answers: 1
    What do you want to happen if you leave it blank?

    Also, if you're using ADO.NET, is there a reason you're not using prepared statements?
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Mar 2010

    I'm having the same issue which I've been trying to figure out for days I have a excel application which displays records with it's associated image and there's a search form as well.

    On the first sheet, 'Click here for the FRU Parts Catalog' is the first form and that works OK. But the problem is with the Search form. You can get to it by clicking on the 'Pesquisar' button. When I try to search it basically doesn't do anything at all. When I debugged it I get the same error as well.
    Syntax error (missing operator) in query expression '...'
    I'm hoping somebody can guide me through this too, as I suck at vb.....

    Thank you so much for your help adn time,
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts