SQLite Sixth lesson Sqlite3_prepare function call Exception analysis

Source: Internet
Author: User
Tags sqlite stmt

Code:

sqlite3_stmt *stmt = NULL;

int ret = Sqlite3_prepare ();

ret = Sqlite3_bind_int (stmt, 1, id);

ret = Sqlite3_step (stmt);

const char *MST = SQLITE3_ERRSTR (ret);


Analysis:

1)

Error message for MST: library routine called out of sequence

Online search is a problem caused by multi-threaded access to the database, the results read through the code, found that no multi-threaded access to the database, and the normal destruction of stmt objects


2)

Try to execute the command statement manually, the error prompt is as follows: no such column:admin

Note that there is a problem with the SQL statement, test the return value of the Sqlite3_prepare function, the error prompt is as follows: SQL logic error or missing database. By modifying the SQL statement, you can finally query normally.


Summary: The Sqlite3_prepare function parses whether the SQL statement is written correctly and returns an error if it is incorrect, causing the following query to fail


SQLite Sixth lesson Sqlite3_prepare function call Exception analysis

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.