If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > ADO.Net SQL query problem!

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-03-10, 18:01
jim_darter jim_darter is offline
Registered User
 
Join Date: Dec 2009
Posts: 4
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.
Reply With Quote
  #2 (permalink)  
Old 03-05-10, 22:58
Teddy Teddy is offline
Purveyor of Discontent
 
Join Date: Mar 2003
Location: The Bottom of The Barrel
Posts: 6,071
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? ***
Reply With Quote
  #3 (permalink)  
Old 03-08-10, 12:37
Ehlie Ehlie is offline
Registered User
 
Join Date: Mar 2010
Posts: 1
Hello,

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,
-Ehlie
Attached Files
File Type: zip Nuno Neves.zip (102.5 KB, 2 views)
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On