Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

compare strings 1

Status
Not open for further replies.

taree

Technical User
May 31, 2008
316
US
I am trying to do a comparison like below and somehow it is not working. Is it because I am trying to compare a value assigned to a variable with the string. How can I fix that?
please help. thank you

Code:
  If String.Compare(strStates1, "ALL", True) = -1 Then
                .Append(" AND R.STATE IN    (SELECT * FROM TABLE (CAST (func_select_state (:BindStates) AS B_state)))")
                cmdDBEVendors.Parameters.Add(New OracleParameter(":BindStates", OracleDbType.Varchar2)).Value = strStates1

            End If
 
Hi,
as a debug step,try displaying the value of strStates1 to see if it may need to be trimmed of trailing spaces before comparing it.



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
how about
Code:
if(strStates1 == "ALL")...

Jason Meckley
Programmer

faq855-7190
faq732-7259
 
thank you all for the response. there is no trailing space.I already trim the trailing space.

what I am trying to do is that if the user select include "ALL" from the dropdown selection then I want to return all the rows for regardless of the selected states.otherwise, I would like the rows for selected states only.

Code:
if(strStates1 == "ALL")...
 
SQL:
...
where
   [other critiera]
and (customer.State = :state or :state is null)
Code:
var p = new parameter("state", varchar);
p.Value = if(string.IsNullOrEmpty(state) == false) ? DbNull.Value : state;
command.Parameters.Add(p);

Jason Meckley
Programmer

faq855-7190
faq732-7259
 
Jason thank you. I will try to apply your sample code. I am not sure how i can use in sql query that use "IN" clause.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top