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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:08:00+00:00 2026-06-11T09:08:00+00:00

I want to save the data from USB into the database sqlite3. Here is

  • 0

I want to save the data from USB into the database sqlite3.

Here is data from USB

char T0[8], T1[8], T2[8], T3[8], T4[8];

I create a table with

const char* Temprature_table = "Create table Temprature_1 (ID INTERGER PRIMARY KEY,Thermo_0 decimal(5,1),Thermo_1 decimal(5,1),Thermo_2 decimal(5,1),Thermo_3 decimal(5,1),Thermo_4 decimal(5,1),time DATETIME)";

then I insert data into the table

result = sqlite3_exec (DB,"Insert  into Temprature VALUES(NULL, T0, T1, T2, T3, T4, time)",0,0,&errmsg);

or

char array[256];
sprintf(array, "Insert into Temprature_1 VALUES(NULL, T0, T1, T2, T3, T4, time)");
result = sqlite3_exec (DB,array,0,0,&errmsg);

but there is a problem: “cannot insert data: no such column: T0”.
I do not know why.
Thanks.

  • 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-11T09:08:02+00:00Added an answer on June 11, 2026 at 9:08 am

    You should use prepared statements to bind values to your query. A regular SQL has the form

    INSERT INTO Temperature_1 (Thermo_0, Thermo_1) VALUES (23.2, 42.3)
    

    A prepared statement looks like

    INSERT INTO Temperature_1 (Thermo_0, Thermo_1) VALUES (?, ?)
    

    which allows for security and performance enhancements. So your final code will look like

    sqlite3_stmt *stmt;
    
    sqlite3_prepare_v2(
      db,
      "INSERT INTO Temperature (Thermo_0, Thermo_1) VALUES (?, ?)",
      -1,
      &stmt,
      NULL
    );
    
    sqlite3_bind_text(stmt, 1, T0, -1, SQLITE_TRANSIENT);
    sqlite3_bind_text(stmt, 2, T1, -1, SQLITE_TRANSIENT);
    
    sqlite3_step(stmt);
    

    See this SQLite introduction to the C API. Your code doesn’t work because you submit the following string to the query engine

    INSERT INTO table (T0);
    

    while the syntax of the INSERT statement looks like

    INSERT INTO <table> VALUES (<expression>[, <expression>[, ...]])
    

    When the database engine evaluates your query, it can’t know that TO happens to be the name of a variable somewhere in your code, thus issue that error. The SQL is a language of its own, it doesn’t share anything with the C context.

    As a final note, the correct spelling seems to be TEMPERATURE, not TEMPRATURE (you missed an E after PR)

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

Sidebar

Related Questions

I want to save data from my database into xml file. I am using
I want to save some data into sqlite database and the read it, there
Possible Duplicate: Save my cookie data to MySQL database? I want save data into
I want to save data in text files and create dictionaries from those files,
So I have an air application that I want to save data from into
I want to save some custom data into application configuration file and I need
I want to save Image in Database with JSON web service .without image data
I want to setup a table that can: Save the data on the user's
I want to save some data automaticly from phones to central db? Is that
I want to read and save some data from this rss feed to in

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.