开发者

Sqlite query troble

i am doing android project by using sqlite db ,in select query i have e开发者_开发问答rror that is cursor bound exception (0) ,my query is :

Cursor c = myDB.rawQuery("SELECT * FROM COMPDETAIL WHERE city='Bangalore' AND service='Hospital';");

by replacing AND by OR it working..

what am I suppose to do, if I want COMPDETAIL by multiple conditions...

Thanks in Advance,


use moveToFirst():

if (c != null) { 
  if (c.moveToFirst()) {
    do { ...


Are you sure such row (with city = 'Bangalore' and service = 'Hospital') exists in your database? AND is perfectly legal keyword in SQLite, there's no reason it wouldn't work and OR would... unless, there's no row matching both criteria, and you still try to fetch it - which will produce something along the lines of out of bounds exception.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜