(Replying to pierr as I joined the list after uralmazamog sent original email)
uralmazamog, The code is incomplete. You are not showing us how you are determining what testValue points to. What is returned if you use the following? sqlite3_open_v2( "testdat", &sqlDB, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL ); sqlite3_prepare_v2( sqlDB, "SELECT b FROM whee WHERE a='bing';", -1,&sqlStat, NULL ); sqlite3_step( sqlStat ); const unsigned char *testValue = sqlite3_column_text( sqlStat, 0 ); printf("testValue=(%s)\n"); Cheers! ________________________________ From: pierr <pierr.c...@gmail.com> To: sqlite-users@sqlite.org Sent: Tuesday, 30 June, 2009 2:42:16 PM Subject: Re: [sqlite] first few characters of varchar() corrupted when SELECTing from a C++ program? uralmazamog wrote: > > Greetings, > > maybe it's just me being stupid, I'll best jump right to the code: > > sqlite3_open_v2( "testdat", &sqlDB, SQLITE_OPEN_READWRITE | > SQLITE_OPEN_CREATE, NULL ); > sqlite3_prepare_v2( sqlDB, "SELECT b FROM whee WHERE a='bing';", -1, > &sqlStat, NULL ); > sqlite3_step( sqlStat ); > const unsigned char *testValue = sqlite3_column_text( sqlStat, 0 ); > > both a and b are varchar(20)s > > calling the query from the command-line tool returns the proper result > "bang", however, running this code the value testValue shows up as "" > for longer strings only the first four characters are corrupted, and the > rest reads okay, what am I doing wrong? > > Try this: char testValue[20]; memcpy(testValue,sqlite3_column_text(sqlStat,0),sqlite3_column_bytes(sqlStat,0)); -- View this message in context: http://www.nabble.com/first-few-characters-of-varchar%28%29-corrupted-when-SELECTing-from-a-C%2B%2B-program--tp24237176p24266020.html Sent from the SQLite mailing list archive at Nabble.com. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ____________________________________________________________________________________ Access Yahoo!7 Mail on your mobile. Anytime. Anywhere. Show me how: http://au.mobile.yahoo.com/mail _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users