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();
}
|