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 7758673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:25:18+00:00 2026-06-01T13:25:18+00:00

I am trying to set an integer and a string value in execSQL statement

  • 0

I am trying to set an integer and a string value in execSQL statement :

mydb.execSQL("UPDATE emptable set age=? where name=?",new int[] {emp_age},new String[] {emp_name});

where emp_age is an integer and emp_name is a String. But this is not working.How can i achieve this?

  • 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-01T13:25:19+00:00Added an answer on June 1, 2026 at 1:25 pm

    Sorry, but I’m not happy with the given answers, and I’ll explain why.

    @hotveryspicy answer is not only ugly but also dangerous. I’ll remind you of the possibility of an SQL-injection, which can cost you your stored data.
    The same is true for @john smith answer.

    @user1318091 answer is incorrect for the same reason that makes all of these answers (including your given example-code) wrong. If you read the documentation, you’ll notice that it says:

    Execute a single SQL statement that is NOT a
    SELECT/INSERT/UPDATE/DELETE.

    on the first line. It also lists alternatives for the above mentioned operations:

    For UPDATE statements, use any of the following instead.

    • update(String, ContentValues, String, String[])
    • updateWithOnConflict(String, ContentValues, String, String[], int)

    If you choose to use the simple update()-method, your query will look like this (untested!):

    ContentValues values = new ContentValues();
    values.put("age", age); // your integer...
    mydb.update("emptable", values, "name=?", new String[]{emp_name});
    

    Also check this question for the correct “where”-syntax: update sql database with ContentValues and the update-method

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

Sidebar

Related Questions

Trying to set up a new project, and running into a weird issue. I
Im trying to set the certificate friendly name during the certificate request/acceptance process. I
I am trying to take in array which contains some integer values/string values from
I am trying to update a field in a table by increasing its integer
I'm trying to use snmpset from netsnmp to set an OID value of type
I'm trying to generate a set of 100 random integers between a fixed range.
Im trying set the single table inheritance model type in a form. So i
Trying to set it so if a certain condition is met then one of
Trying to set up a dependency in C++ with a parent-child relationship. The parent
Trying to set a flag in the post to allow processing or not. The

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.