Re: [sqlite] Insert record in c++

2013-01-23 Thread Stephan Beal
On Wed, Jan 23, 2013 at 2:36 PM,  wrote:

> String Data = "INSERT INTO friend(name, address, age)
> VALUES('John','Anywhere here','25')";
>
> How would you actually pull the VALUES from variables and use them.  A
> complete example will be very helpful.
>

Google for "sqlite3_bind example" and you'll find many examples. You'll
also need to read up on "sqlite3_prepare()" and "sqlite3_prepare_v2()",
both described in detail at:

http://www.sqlite.org/c3ref/prepare.html

In the _abstract_ it looks like:

statement = prepare("INSERT INTO t(a,b,c) VALUES(?,?,?)");
bind( statement, 1, "foo" );
bind( statement, 2, "bar" );
bind( statement, 3, 32 );

And the above pages reveal the exact syntax/APIs to use.

Note that the "String" class shown above is platform-specific and won't be
understood by the C API - it uses (char const *) and (unsigned char const
*).

There are a number of C++ wrappers out there. AFAIK none of them are
"official", but here's the one i currently use/maintain:

http://fossil.wanderinghorse.net/wikis/cpdo/?page=cpdopp

-- 
- 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] Insert record in c++

2013-01-23 Thread roystonjames


Hi Everyone, 



I am extremely new to sqlite and using sql syntax.  I have been searching the 
web for examples but I am not finding any that actually helps me understand 
what I am doing.  



Can someone show me in c++ how to insert a record into the database utilizing 
variables?  The examples I see all have hard coded values, even when I try to 
put a variable instead of the values my code never compiles. 



Example, I found this code 



String Data = "INSERT INTO friend(name, address, age) VALUES('John','Anywhere 
here','25')"; 



How would you actually pull the VALUES from variables and use them.  A complete 
example will be very helpful. 





I am currently trying to write a small demo that will show how to CreateDB, 
OpenDB, Create Multiple Tables at once or just one table, Insert Record, Delete 
Record, Next Record, Prior Record etc etc.  Just the basics so I will at least 
know how to use code. 




Thanks
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users