Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7795737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:09:20+00:00 2026-06-01T23:09:20+00:00

I am querying my db. When I use an int for the selection part

  • 0

I am querying my db. When I use an int for the selection part I get the info returned I want. When I use a string for selection I get nothing returned. Is there a different way to query when using a string or am I doing something wrong. This function worked when I passed in an int, but when I pass in a string it does not work. I used breakpoints and the parameters are correct going into the function, but it does not retrieve the data from the db.

Here is the code

 public String childFound(String item_name)throws Exception
{

    Cursor c = db.query(DB_TABLE, new String[] { KEY_INSPECTION_ID, KEY_ITEM_NAME},
            "item_name="+ item_name, null, null, null, null);

       int id=c.getColumnIndex(KEY_ITEM_NAME);
        c.moveToFirst();
        String result=c.getString(id);
       c.close();
       return result;

}

If I change the String item_name to int inspectionItem it works. I am also including where I declared my variable for the db.

 public class InspectionRecordsTableDBAdapter {
private static final String KEY_ROWID = "_id";
private static final String KEY_INSPECTION_ID = "inspection_id";
private static final String KEY_PARENT_NAME = "parent_name";
private static final String KEY_ITEM_NAME = "item_name";
private static final String KEY_COMMENT = "comment";
private static final String KEY_STATUS = "status";
private static final String DB_TABLE = "inspection_records";
private Context context;
private SignalSetDBHelper dbHelper;
private SQLiteDatabase db;
private SQLiteOpenHelper openHelper;

If you need more code let me know.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T23:09:21+00:00Added an answer on June 1, 2026 at 11:09 pm
    "item_name="+ item_name
    

    should be

    "item_name='"+ item_name + "'"
    

    Think you are missing the quotes

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use a custom class that could handle querying easily. Are there
public class Players { public int GUID { get; set; } public string Name
Is there a way to use http_build_query() without having it URL encode according to
What query would I have to use to check if the querying user has
in my php5 code i want to use the UNIX_TIMESTAMP function to convert a
I have a Dictionary<int, string> cached (for 20 minutes) that has ~120 ID/Name pairs
I am looking for a nice simple LINQ query that can get an item
In my application I'm querying a database via the use of a PHP script.
I am having difficulties with a complicated (for me any way) query. The table
I'm wondering if there's any relatively easy way to extend NHibernate to support F#'s

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.