java - SQLite query throwing exception in Android -
I am trying to create an SQLite database in my Android application. I know that contact in the database because when I add it to go and do, try to find the ID he object when I first tried to find the last name, however, it throws an exception and Im Left with a redundant reference. Query:
cursor = mDb.query (DB_CONTACTS_NAME, new String [] {KEY_ID, KEY_LAST_NAME, KEY_FIRST_NAME, KEY_EMAIL_ADDRESS, KEY_ORGANIZATION_NAME, KEY_LABEL, KEY_LABEL_POSITION}, KEY_FIRST_NAME + "=" + first + " And "+ KEY_LAST_NAME +" = "+ Last, Free, Empty, Null, Zero);
Ive also tried to find by name first and just by the last name. Edit
as a single result. Aurelius: while compiling: Select _ id, last_name, first_name, EMAIL_ADDRESS, organization_name exception SQLite exception
is a column such labels, where label_position contacts first_name = Marcus and Last_name = Andelius
Anything else is trying to make the first selection when the last name
such a column: Marcus: while collection: select _ id, last_name, first_name, EMAIL_ADDRESS, organization_name, label, where first_name = Marcus from label_position contacts
You will need to quote literal strings. This should work:
cursor = mDb.query (DB_CONTACTS_NAME, new String [] {KEY_ID, KEY_LAST_NAME, KEY_FIRST_NAME, KEY_EMAIL_ADDRESS, KEY_ORGANIZATION_NAME, KEY_LABEL, KEY_LABEL_POSITION}, KEY_FIRST_NAME + '=' '+ first + "and" + KEY_LAST_NAME + "= '" + final +' 'blank, blank, blank, blank);
or when SQL sees interpreter
first_name = marcus
You do not want to know that 'Marcus' is not a table name or a variable
On one side note Trying to find the last name "Billy" "; Table contacts drop, "
Instead of using a query that leads to the logic list, look for documents for something like
string [] myArguments = new string [] {first, last}; cursor = mDb.query (contact with "Contact * where first_name = and last_name = ?;", MyArguments);
It is more secure in your version if the 'first' or 'last' variable contains the control characters which are defined according to the command of SQLite If you can break your database system. did not ... never
Comments
Post a Comment