开发者

Sqlite query troble

开发者 https://www.devze.com 2023-02-26 11:36 出处:网络
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 :

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

精彩评论

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