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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SetFilter() error?

Status
Not open for further replies.

kaul125

Programmer
Jan 29, 2002
87
US
I'm having difficulty setting the proper filter string to SetFilter().

I'm trying to filter my dataset by getting all last names that begin with a certain letter.

Here is my code:

ids_lastnames.SetFilter("last_name like '"+ as_char +"'")

as_char = A%

When I debug this setfilter returns -1.

I've tried, for example, Left(last_name,1) = as_char as the filter string and I get the same error.

What would be the proper string format for SetFilter() to get all last name like 'A%'?

I'm using PB6.5 and Sql Anywhere as the data base

Keith
 
The code looks fine.
1. Try to build the filter string in a variable
ls_str = "last_name like '"+ as_char +"'"
and see if it is built as expected. Ideally it should return
"last_name like 'A%'" (value in double quotes). Similarly, if you use left function, it should result in "left(last_name,1) = 'A'"
2. Check out just in case last_name is not the correct column name





RT
 
I would first check that the LIKE operator in a datawindow expression will work in you version of PowerBuilder. I know it works in 7 and greater, but I am not sure of prior to that (I know it didn't exist in 3 when I started with PB).

The best way to do this is to put the resolved expression (last_name like 'A%') directly into the painter and press the validate button to see if it will work.

 
Thanks!!

All of your suggestions worked fine. For what ever reason, which I don't know, when you pass a string variable to the SetFilter function it works fine. However, when you create the string by itself, like below, it does not work:

ids_lastnames.SetFilter("last_name like '"+ as_char +"'")


Keith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top