Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

SQLite Error Please Help!

Name: Anonymous 2009-07-21 17:27

I have been trying to save this string to the SQLite database for a while now and no luck online! I am using Visual Studio 2008 and using a SQLite C++ class. Here is my code:

int main()
{
std::string s;
SQLITE3 sql("apptz.sql");
string hey = "heyy";

//This works when I manually input text
sql.exe("INSERT INTO appts (title) VALUES ('First Appt.')");

//This does not work when I use the variable name instead of manually
sql.exe("INSERT INTO appts (title) VALUES (hey)");

return 0;
}

If you can help it will be greatly appreciated. Thank you!

Name: Anonymous 2009-07-21 17:32

is it something to do with the string class or because you need to sprintf the value of hey into the string to execute. also how do you expect us to do anything without any sort of debug messages or helpful information other than `it doesn't work'?
jesus christ anyone who asks for programming help is too retarded to do it right, and anyone who's intelligent enough to ask for help properly can figure out the problem for itself. thus, programming help forums technically cannot exist.

Name: Anonymous 2009-07-22 11:09

>string hey = "heyy";
>sql.exe("INSERT INTO appts (title) VALUES (hey)");

EPIC FAIL

If you can't guess by yourself what's wrong, you don't deserve any programming job.

"VALUES(hey)" is treated as is, i.e. passed to the SQL driver that exactly way. As the SQL driver does not know what 'hey' is ─I bet it says "column not found"─, it fails.

You should have written this:

sql.exe("INSERT INTO appts (title) VALUES (" + hey + ")");

Well, maybe this won't work on C. You'll have to workaround string concatenation by yourself.

Name: Anonymous 2010-12-23 13:24

Don't change these.
Name: Email:
Entire Thread Thread List