Return values are your friends.  Use them.  Store the error code from every 
sqlite function call, and if the error code is not SQLITE_OK (NOTE:  Check that 
that is the correct name.), then display what the error code is.  In 
particular, what is the return value of your sqlite3_bind_text() function call?

If the documentation of a function states that a parameter requires a named 
special value, use that name.  The fifth argument should be a destructor 
function pointer, SQLITE_STATIC or SQLITE_TRANSIENT.  Read the documentation to 
understand what each one means.

Learn to cringe every time you put a constant value into your code.  People 
often call hard-coded constants "magic numbers" because they apparently showed 
up magically, since there's no other explanation of where they came from.  
Where did "140" come from?  Why do you need it?  The parameter requires the 
length of a string.  So use strlen() (again, check the correctness.  It's been 
so long since I've used these functions, the name could be wrong) to calculate 
the actual length of the string.  The documentation states that if the fourth 
argument is not negative, it is the byte offset where the null terminator 
should be, and any null terminators before that are included in the bound 
string, and if any null terminators are included in the bound string, behavior 
is undefined.  That's exactly the situation you have.  

And when you use strlen() or whatever you use to calculate the length of the 
string, be careful to take into account the difference between bytes and 
characters.  The sqlite3_bind_text() call requires bytes, but your characters 
may be one or two bytes.

RobR
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to