hy all i have problem with my program
here is my code
# include <iostream>
# include <sqlite3.h>
# include <sstream>
using namespace std;
int main()
{
sqlite3 *db;
sqlite3_stmt *res;
int rc;
string nama;
int umur;
rc=sqlite3_open("namaorang.db",&db);
if(rc!=SQLITE_OK)
{
cout<<sqlite3_errmsg(db);
}
else
{
cout<<"Nama : ";cin>>nama;
cout<<"Umur : ";cin>>umur;
stringstream sql;
sql<<"INSERT INTO data (nama,umur)VALUES ('"<<nama<<"','"<<umur<<"');";
rc=sqlite3_prepare(db,sql.str().c_str(),-1,&res,NULL);
if(rc!=SQLITE_OK)
{
cout<<sqlite3_errmsg(db);
sqlite3_close(db);
}
rc=sqlite3_step(res);
if(rc!=SQLITE_OK)
{
cout<<sqlite3_errmsg(db);
}
}
sqlite3_finalize(res);
sqlite3_close(db);
}
when i run my program and input the query , this program return unknown error,, how to fix this.. meanwhile the error is unknown,, how to known the error.. thanks for read this
if(rc!=SQLITE_OK) { cout<<sqlite3_errmsg(db); sqlite3_close(db); }
Seems like you need return
here, but you continue to work with results after error instead.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.