I am using c++ with sqlite3

I have a database(test.db) with a table of testTable

inside the testTable it has the following attribute


I tried inserting a randomText into the database after my input but it's not inserting into the database.

my code http://pastebin.com/TvuNqFsF

need help. thanks

It looks like main() is calling the wrong function. insertIntoTable() instead of insertValuel()

IMO insertValue() is too complicated, paramitizing the sql like that is not necessary.

sprintf(sql,"INSERT INTO table(id,text) VALUES(%d,\"%s\")",1,randomText.c_str());

Now with that simple line call sqlite3_exec(), as shown in this 5-minute tutorial.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.