|
-
May 6th, 2013, 01:56 PM
#1
Thread Starter
New Member
[RESOLVED] Oledbcommand where....or....or
Hi all,
I need a quick response to my problem. I need to write an OLEDBCOMMAND that I cannot figure out how to structure. It should look for an access database for a specified value and check two column. If only one or both of the checked columns have specified value, it should select the row. For instance,
COLUMN1............COLUM2....COLUMN3
ROWx.................OK...........NOT OK
ROWx.................OK...........OK
ROWx................ NOT OK.....NOT OK
It should be something like
comm.CommandText = "Select * from table WHERE COLUMN1='" combobox.text & ''," & COLUMN2=OK "' OR '" & COLUMN3=OK & "'"
It should return first and second rowx if combobox value is rowx.
Thanks for your helps.
Last edited by ew03; May 6th, 2013 at 01:59 PM.
-
May 6th, 2013, 02:13 PM
#2
Re: Oledbcommand where....or....or
Well, we can give you a quick response, but it may not be a good one. I'm not even sure what the real question is. There are some missing & in your SQL statement, but that's probably just because you typed it freehand into the post, as you have the rest in place. There's also an issue with the "," that you concatenate in, as that isn't going to work, but I think that just replacing that with an AND might do, especially if you add some parentheses to make it clear whether the And or the Or takes precedence. You also seem to be using the right object.
So what is it you are actually looking for?
My usual boring signature: Nothing
 
-
May 6th, 2013, 02:27 PM
#3
Thread Starter
New Member
Re: Oledbcommand where....or....or
Hi Shaggy,
Even though i could not state myself clearly, you greatly helped me with your suggestion with parantheses. It works like a charm. I changed my statement as,
comm.CommandText = "Select * from table WHERE COLUMN1='" & ComboBox1.Text & "' AND (COLUMN2='OK' OR COLUMN3='OK')"
Thanks a million.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|