0

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

_id|randomText

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

2
Contributors
2
Replies
16
Views
3 Years
Discussion Span
Last Post by thomas_14
0

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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.