int sqlite3_prepare_v2(
 sqlite3 *db, /* Database handle */
 const char *zSql, /* SQL statement, UTF-8 encoded */
 int nByte, /* Maximum length of zSql in bytes. */
 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
 const char **pzTail /* OUT: Pointer to unused portion of zSql */
 );
 /*** Please note that this program is not ment to be funtional, it is only 
here to serve as a research bench. However, I am trying to make it as 
realisting as possible, so to keep it as real life as possible.***/
 void mydb(){
 sqlite3 *db;
 std::string db_name("test");
 std::string my_name("Programmer");
 int my_age = MAX_INT;
 std::string vfs("win32");
 //1 .) open||create a data base
 rc = sqlite3_open_v2(dbName.c_str(), &db, SQLITE_OPEN_READWRITE | 
SQLITE_OPEN_CREATE, vfs.data());
 if(rc != SQLITE_OK){
 sqlite3_close(db_name);
 std::cout << "naaa, you ain't got it yet... press any key and keep trying." << 
std::endl;
 std::cin.get();
 exit(-1);
 } else {
 std::cout << "Welcome to a whole new world!" << std::endl;
 std::cin.get();
 }

 *//2 . ) create a table 
 std::string create_table("CREATE TABLE friend (name TEXT, address TEXT, age 
INT)");
 rc = sqlite3_prepare_v2(
 &db, /* Database handle */
 creat_table.c_str() , /* SQL statement, UTF-8 encoded */
 ??, /* Maximum length of zSql in bytes. */
 ??, /* OUT: Statement handle */
 ?? /* OUT: Pointer to unused portion of zSql */
 );*
 ...
 }

 std::string create_table("CREATE TABLE friend (name TEXT, address TEXT, age 
INT)");
 rc = int sqlite3_prepare_v2(
 db, /* Database handle */
 creat_table , /* SQL statement, UTF-8 encoded */
 ??, /* Maximum length of zSql in bytes. */
 ??, /* OUT: Statement handle */
 ?? /* OUT: Pointer to unused portion of zSql */
 );Here is where my question rises, how can I know "Maximum length of zSql in 
bytes"? All I know is that the maximum length of std::string is 255. Also, what 
are the values for the last two paramenters? ("OUT: Statement handle" and "OUT: 
Pointer to unused portion of zSql").

 Thanks in advance

----- Original Message -----
From: Stephan Beal
Sent: 06/17/12 02:35 PM
To: General Discussion of SQLite Database
Subject: Re: [sqlite] C++ programming - int sqlite3_open_v2() question

 On Sun, Jun 17, 2012 at 7:39 PM, Arbol One <arbol...@programmer.net> wrote: > 
std::cout << "naaa, you ain't got it yet... press any key and keep > trying." 
<< std::endl; > std::cin.get(); > Glad it helped. Pedantic note: cin.get() will 
wait for ENTER to be pressed before returning, AFAIK. There is no portable way 
(in C/C++) to grab only the next keystroke from the console. > Now, my next 
step is to create data tables, but that will be on another > email. > 
sqlite3_exec(), sqlite3_prepare(), sqlite3_bind_xxx(), sqlite3_step(), 
sqlite3_finalize() -- ----- stephan beal 
http://wanderinghorse.net/home/stephan/ http://gplus.to/sgbeal 
_______________________________________________ sqlite-users mailing list 
sqlite-users@sqlite.org 
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to