views:

152

answers:

3

Hi,

I have this sql statement SELECT * FROM Language WHERE LanguageCode=? where LanguageCode is a varchar(2).

When I use sqlite3-prepare-v2 on that statement I got SQLITE_ERROR but if I use SELECT * FROM Language WHERE LanguageID=? where LanguageID is the primary key numeric identity field the statement compiles just fine.

Is there any issue filtering by a varchar field using WHERE statement?

Thanks

A: 

I think there should be no issue with the where statement by using a varchar field. Maybe you are having problem with passing the parameter. Try to print to NSLog and see the statement that is executed, and execute it with the sqlite command prompt to see if you have return values.

sfa
A: 

Be sure your ? is wrapped in single quotes.

SQLite should also give you an error string which tell you why there is an error.

Winder
A: 

Try to call sqlite3_errmsg and check the error string returned from that call. It should give you a more detailed information about what went wrong.

Claus

Claus Broch