Click here to Skip to main content
15,887,676 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello!
When I fetch the data from data base error is occur named index out of bound.

Query written by me is as follow:
C#
public Cursor getid(String nm2) {
   String qry = "SELECT  Family_member,Activity  FROM " + TABLE_NAME_FAMILY_DETAIL + " WHERE Family_member = '" + nm2 +"' " ;
		
   Cursor cur = db.rawQuery(qry1, null);

   return cur;
}

When I enter specific column names and try to fetch data from database so error occur but when I take all columns(e.g., SELECT * from....) then it will get output.so please reply me as soon as possible.

Hoping for your favorable reply.
Thank you.
Posted
Updated 10-Dec-14 1:47am
v2
Comments
Monicavensaslas 10-Dec-14 5:26am    
Is your table name is TABLE_NAME_FAMILY_DETAIL ??

Y are you giving the table name within doublequotes?? try this....

SELECT Family_member,Activity FROM TABLE_NAME_FAMILY_DETAIL WHERE Family_member = '" + nm2 +"' "
Richard MacCutchan 10-Dec-14 5:35am    
Don't use string concatenation for SQL, use proper parameterised queries. Learn about SQL injection.
Richard MacCutchan 10-Dec-14 5:34am    
Don't use string concatenation for SQL, use proper parameterised queries. You also need to check that your returned cursor contains records, and has the fields that you are trying to access.
Mehul Tank 3-Jan-15 5:17am    
thank you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900