How to use OR condition from Combox box in VB.net

Hi There,
I have an application using Vb.net 2003. I have my backend as ms access.
I have made a oledbdataadapter1
with the following query
[WO #],  PO,  [Qty Ord]  Loc, ID FROM [Ftbl] WHERE  (Loc = ?)

the back end table Ftbl has data for 3 loc AZ, TX, AK

I have the function

Private Sub CBTN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CBTN.Click
        Try
           
            OleDbDataAdapter1.SelectCommand.Parameters("Loc").Value = CoBox.Text
            ' CALL FUNCTION TO FILL
            FnR()
            'CHECK FOR ADDITION OF NEW ROW
            Dim changer As Smm = New Smm
            Dim newRow As DataRow = changer.Tables("Ftbl").NewRow()
            changer.Tables("Ftbl").Rows.Add(newRow)
            AddHandler OleDbDataAdapter1.RowUpdated, New System.Data.OleDb.OleDbRowUpdatedEventHandler(AddressOf OleDbDataAdapter1_RowUpdated)

        Catch ex As Exception
            MsgBox(ex.Message + vbCrLf + ex.Source & vbCrLf & vbCrLf & ex.StackTrace, MsgBoxStyle.Critical, "Error")
        End Try

I give the value to
OleDbDataAdapter1.SelectCommand.Parameters("Loc").Value = from a combox box
and on the Combo box I have the following list
AZ
TX
AR
AZ OR TX OR AR

AZ OR TX OR AR doesn't work when I want to see data for all 3 location. What is the right format so I can feed it "Loc" so it see it as
Loc = AZ or Loc = TX or Loc = AR  
or even better is there a way I can say ALL so my combo box list has it as
AZ
TX
AR
ALL    
so when they select ALLwill indicate  AZ or TX or Ar for LOC parameter and pull info for 3 loc.
I will appreciate if somebody can help me.
thanks
SivasanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

derftoyCommented:
I would use the SQL IN statement:

http://www.w3schools.com/sql/sql_in.asp

You will have to split out the data from the drop down list though.


Try that.
0
SivasanAuthor Commented:
Hi Derftoy,
Thank for your reply, what does it mean "to split out the data from the drop down list"
thanks
0
derftoyCommented:
Since your using paramaters for that one, I am not sure how the best way to go about it would be.  Not sure if a paramerterized item can have multiple values.

The SQL statement you have is a select with parameteres.  I don't use them.  I just build the sql and then execute it.

0
Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

CodeCruiserCommented:
I usually use two parameters in such a situation.

@applyfilter Bit
@filter Varchar

IF(@applyfilter = 1)
BEGIN
   Select ... Where columnname = @filter
END
ELSE
BEGIN
   Select ...
END


The above syntax is for SQL Server but I hope it requires little changes for Access.
0
SivasanAuthor Commented:
Hi codecrusier
Thanks for your response,
is it possible to use if statement sql  on the oledbadapter or can I only use it under the Onclick event?
Right now I'm using oledbadpater to make the query.
thnks
0
CodeCruiserCommented:
The if condition is in the stored procedure. It does not matter where you call your stored procedure. Just supply the appropriate parameter values and it should work for you.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SivasanAuthor Commented:
Hi Codecruser:
Though your answer was not exactly to my situation, I still used your concept and understood how to use the IF statement.
Under the Onclick event
i directly used the iF and checked the value of combo box, if value ='ALL'
i used one oledbadapter if not the other oledbadpater it worked.
Thanks a lot for your feed back.
0
CodeCruiserCommented:
Glad to help :-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.