tags:

views:

33

answers:

1

See title for explanation.

Here is the method I'm using:

public Cursor getClientByName(String name) throws SQLException {

    name = name.trim();

    Cursor mCursor = 

        mDb.query(true, DATABASE_TABLE, new String[] {KEY_ROWID, KEY_NAME}, KEY_NAME + "=" + name, null,
                null, null, null, null);

    if (mCursor != null) {
        mCursor.moveToFirst();
    }

    return mCursor;

}

And here is the call to the method:

list.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view,
            int position, long vId) {

            String name = ((TextView) view).getText().toString();

            // Toast.makeText(AvoidForeclosure.this, name, Toast.LENGTH_LONG).show();

            Cursor cD = db.getClientByName(name);
            cD.moveToLast();
            int id = cD.getInt(0);

          Intent intent = new Intent();
          intent.setClass(view.getContext(), CurrentMarketValue.class);
          intent.putExtra("clientId", id);
          startActivity(intent);

        }
      });

Any idea why it would be throwing the "No Column Found with name=Test", although my DB explorer shows there is indeed a column named name and a value in a row named Test?

A: 
public Cursor getClientByName(String name) throws SQLException {

        name = name.trim();

        String q = "SELECT _id, name FROM " + DATABASE_TABLE + " WHERE name=?";

        Cursor mCursor = mDb.rawQuery(q, new String[] { name });


        if (mCursor != null) {
            mCursor.moveToFirst();
        }

        return mCursor;

    }

Fixes this.

Allen Gingrich