On 12/17/2010 5:23 PM, john darnell wrote: > I could not figure out how to pipe my info to a file (I guess I am > still a very young (at 57 years) newbie when it comes to SQLite) so I > tried something else. In my code, I hardcoded the data instead of > using variables. Here is a copy of one of the statement groups I am > using to bind data to the insert statement: > > idx = -1; idx = sqlite3_bind_parameter_index(ResultStmt, ":disp"); > sqlite3_bind_text(ResultStmt, idx, CurrentName -> > second.GetDisplayName().c_str(), -1, SQLITE_STATIC);
GetDisplayName returns a temorary string, which is destroyed at the semicolon, and deallocates the internal buffer it maintains. c_str() returns a pointer to that buffer, which promptly becomes a dangling pointer. Yet, by passing SQLITE_STATIC, you promise that the pointer will be valid at least until sqlite3_step call. Pass SQLITE_TRANSIENT instead, or make sure the string outlives the execution of the statement. -- Igor Tandetnik _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users