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

Recommended Answers

All 2 Replies

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.

thank you

Be a part of the DaniWeb community

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