Hello nshaw, std::string m_sSQL = "CREATE TABLE IF NOT EXISTS "; m_sSQL += g_pszTableName; m_sSQL += "(" ; m_sSQL += "AR_Filename TEXT PRIMARY KEY," ; m_sSQL += "AR_Subject TEXT ," ; m_sSQL += "AR_From TEXT ," ; m_sSQL += "AR_Group TEXT ," ; m_sSQL += "AR_GoodBlocks INTEGER" ; m_sSQL += ");" ;
HRESULT hr = Exec ( m_sSQL.c_str() ); // // Paramaterized insert with values bound later // std::string m_sSQL = "INSERT OR IGNORE INTO "; m_sSQL += g_pszTableName; m_sSQL += " VALUES (?,?,?,?,?,?,?);"; std::string m_sSQL = "insert into family (member,age) values "; m_sSQL += "(" ; m_sSQL += name; m_sSQL += "," ; m_sSQL += "age" ; m_sSQL += ");" ; if you want to do straight C you need something like a sprintf or use SQLite's printf routines. I build everything in a C++ string then pass is using the ".c_str()" operator. I recommend parameterized inserts too. C Monday, April 9, 2007, 12:59:27 PM, you wrote: n> Help! n> I've done everything I can think of to pass arguments to SQLite and nothing n> is working. If anyone has information on how to do it, I'd appreciate it. n> Here's a code segment: n> #include <iostream> n> #include <stdio.h> n> #include <stdlib.h> n> #include "util.h" n> #include <sqlite3.h> n> using namespace std; n> int main (int argc, char **argv) n> { n> sqlite3 *db; // --- database n> char *zErr; n> int return_code; n> char *sql; n> // ----- variables for database input --------------- n> char name[30]; n> int age; n> // ----- create or open the database ---------------- n> return_code = sqlite3_open("Family.db", &db); n> // ----- error creating or opening the database ----- n> if (return_code) { n> fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db)); n> sqlite3_close(db); // --- close database n> exit(1); n> } n> // ----- enter data into local variables ------ n> cout << "Enter name: "; cin.getline (name, 30); n> cout << "Enter age: "; cin >> age; n> // ----- enter a record into the database ----- n> sql = "insert into family (member,age) values (name, age)"; // -------- n> HERE'S WHERE COMPILE BUSTS n> The error is that no column exists called 'age.' I've tried passing name n> and age as pointers, as references, I've tried declaring them as pointers, n> etc. and nothing can be passed. If I pass absolute arguments ("Nick", 30) n> it works. n> Again, I appreciate any and all help! n> Regards, n> Nick. -- Best regards, Teg mailto:[EMAIL PROTECTED] ----------------------------------------------------------------------------- To unsubscribe, send email to [EMAIL PROTECTED] -----------------------------------------------------------------------------