LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   sending queries in sqlite3 database via c API (https://www.linuxquestions.org/questions/programming-9/sending-queries-in-sqlite3-database-via-c-api-4175425538/)

batman4 09-04-2012 04:12 AM

sending queries in sqlite3 database via c API
 
HI I want to send multiple queries through this program sqlite3_prepare() .pls help

Code:


#include <stdio.h>
#include "sqlite3.h"
int main(void) {
        sqlite3* db = 0;
        sqlite3_stmt* stmt = 0;
        int retcode;
        retcode = sqlite3_open("test.db", &db); /* Open a database named MyDB */
        if (retcode != SQLITE_OK){
                sqlite3_close(db);
                fprintf(stderr, "Could not open MyDB\n");
                return retcode;
        }
        else
            printf("connection established\n");

        retcode = sqlite3_prepare(db, "select * from abc", -1, &stmt, 0);
        if (retcode != SQLITE_OK)
        {
                sqlite3_close(db);
                fprintf(stderr, "Could not execute SELECT\n");
                return retcode;
}
return 0;
sqlite3_close();
}


Ygrex 09-06-2012 12:58 AM

1. why do you use deprecated _prepare instead of _prepare_v2?
2. where is _step calling?
3. where is _finalize?


All times are GMT -5. The time now is 07:14 PM.