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

  • Home
  • SEARCH
  • 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 8081371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:42:39+00:00 2026-06-05T16:42:39+00:00

I have my SQLite db storing my info and it works ok. However I

  • 0

I have my SQLite db storing my info and it works ok. However I want to use Parameter.

I modify this line to set the values and works ok:

cmd.CommandText = String.Format("INSERT INTO users ("+data[0]+", "+data[1]+") VALUES (@4,@5);");
p = new SQLiteParameter("@4", System.Data.DbType.String);
p.Value = data[4];
cmd.Parameters.Add(p);
p = new SQLiteParameter("@5", System.Data.DbType.String);
p.Value = data[5];
cmd.Parameters.Add(p);

ERROR: But if I want to use Parameter to the column’s names it say there’s a syntax error near "@0":

cmd.CommandText = String.Format("INSERT INTO users (@0, @1) VALUES (@4,@5);");
    p = new SQLiteParameter("@0", System.Data.DbType.String);
    p.Value = data[0];
    cmd.Parameters.Add(p);
    p = new SQLiteParameter("@1", System.Data.DbType.String);
    p.Value = data[1];
    cmd.Parameters.Add(p);
    p = new SQLiteParameter("@4", System.Data.DbType.String);
    p.Value = data[4];
    cmd.Parameters.Add(p);
    p = new SQLiteParameter("@5", System.Data.DbType.String);
    p.Value = data[5];
    cmd.Parameters.Add(p);

It’s possible to use Parameter in this case? What’s wrong with the code?

Thanks for your help!

  • 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-05T16:42:40+00:00Added an answer on June 5, 2026 at 4:42 pm

    You cannot parameterize column names. first approach is ok.

    OR you can send all these as parameters to stored procedure and build query dynamically at db level and execute.

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

Sidebar

Related Questions

I have normal sqlite database and want to use fts3. As mentioned in http://www.sqlite.org/fts3.html
I have an sqlite database I want to distribute with my application. It's about
I have a SQLite database that contains a huge set of log messages. I
I have Python code that pulls info from a sqlite database and then write
In my application I have a sqlite database that looks like this: CREATE TABLE
I have an SQLite Database in which I am storing images as BLOB using
I have an app with an SQLite database for storing information for a user's
I will be storing datetime values in an SQLite database (using Delphi and the
I have an SQLite DB that's storing all coordinates + description to show them
I have been trying to follow this tutorial: http://www.androidhive.info/2012/01/android-login-and-registration-with-php-mysql-and-sqlite/ . It is to create

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.