Sivasan
asked on
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.SelectCo mmand.Para meters("Lo c").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").New Row()
changer.Tables("Ftbl").Row s.Add(newR ow)
AddHandler OleDbDataAdapter1.RowUpdat ed, New System.Data.OleDb.OleDbRow UpdatedEve ntHandler( AddressOf OleDbDataAdapter1_RowUpdat ed)
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.SelectCo mmand.Para meters("Lo c").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
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.SelectCo
' CALL FUNCTION TO FILL
FnR()
'CHECK FOR ADDITION OF NEW ROW
Dim changer As Smm = New Smm
Dim newRow As DataRow = changer.Tables("Ftbl").New
changer.Tables("Ftbl").Row
AddHandler OleDbDataAdapter1.RowUpdat
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.SelectCo
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
ASKER
Hi Derftoy,
Thank for your reply, what does it mean "to split out the data from the drop down list"
thanks
Thank for your reply, what does it mean "to split out the data from the drop down list"
thanks
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.
The SQL statement you have is a select with parameteres. I don't use them. I just build the sql and then execute it.
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.
@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.
ASKER
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
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.
Glad to help :-)
http://www.w3schools.com/sql/sql_in.asp
You will have to split out the data from the drop down list though.
Try that.