1

I want to execute a ManagedQuery but am getting a error in my log:

Query

 Cursor cursor = managedQuery(GroceryListContentProvider.NOTES_URI,projection,Notes.NOTE_TITLE+"="+S+" AND "+ Notes.NOTE_DATE+"="+S1, null, null);

Error Log

02-21 16:00:52.395: E/AndroidRuntime(22534): java.lang.RuntimeException: Unable to start activity ComponentInfo{net.schuemie.GroceryList/net.schuemie.GroceryList.shoppinglist}: android.database.sqlite.SQLiteException: near "new": syntax error: , while compiling: SELECT item_name FROM notes WHERE (title=shop new AND date=12/2/12) ORDER BY title
1
  • 3
    It's not a compilation error, it's a runtime error, hence RuntimeException ;-) Commented Feb 21, 2012 at 11:01

3 Answers 3

1

remove "new" from query and add quotes to string values

SELECT item_name FROM notes WHERE (title='shop' AND date=12/2/12) ORDER BY title
Sign up to request clarification or add additional context in comments.

1 Comment

SELECT item_name FROM notes WHERE (title=shop new AND date=12/2/12) ORDER BY title - this is your query from error log. look carefully, new can be in title field value, so your query must look loke this SELECT item_name FROM notes WHERE (title='shop new' AND date=12/2/12) ORDER BY title
0

Update

String where = "title='"+nameOfTitle+"' And date="+date+" "; 


Cursor cursor = managedQuery(GroceryListContentProvider.NOTES_URI,null,where,null,null);

9 Comments

using this query i printed in log cat to see hw many rows its returning but it is showing as zero.............bt when i keep the where clause part as null it will print in the log that there are four rows..........y do i have this error??
can u post that both query which u r printing in your logcat
Cursor cursor = managedQuery(GroceryListContentProvider.NOTES_URI,null,Notes.NOTE_TITLE+"='"+S+"' AND "+ Notes.NOTE_DATE+"="+S1, null, null);when i use this it returns zero rows
Cursor cursor = managedQuery(GroceryListContentProvider.NOTES_URI,null,null, null, null);when i use this it returns four rows which are present in the database
is there anyone who could give a solution for this??
|
0

Did you try to do this

title="shop"

or

title='shop'

1 Comment

S is currently my title and checking it with my column name in my database

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.