Hi,
There is a very strange problem when I play with the sqlite-ce database.
I put the database file and my application program together in the same folder.
I call sqlite3_open(), the database can be opened properly. I call
sqlite3_step(), it return SQLITE_ROW, that means it found the record in the
database.
However, if I put the database file in the other disk, the problem occurred. I
call sqlite3_open(), the database can still be opened properly. However, I call
sqlite3_step(), it return SQLITE_DONE, that means it cannot found the record in
the database.
Actually, the database file is exactly same, only different is the store place.
I wonder whether it is limitation for sqlite-Wince?
Any comment? Thanks! Code is as follows:
{
sqlite3 *db;
char *zErrMsg = 0;
int rc, length;
char *sqlcmd;
sqlite3_stmt * stat;
TCHAR MsgChar[ 256 ], MsgTmpChar[ 256 ];
// * Put in the same folder, it works properly. *
// rc = sqlite3_open( "initprint.db", &db);
// * Put in the different folder, it cannot work properly. *
rc = sqlite3_open( "\\FlashDisk\\System\\initprint.db", &db);
if( rc )
{
sqlite3_close(db);
return false;
}
sqlcmd = sqlite3_mprintf( "SELECT * FROM PRINT WHERE TAGTYPE=%d AND
BARCODE='%s';", intTagType, chrBarCode );
rc = sqlite3_prepare( db, sqlcmd, -1, &stat, 0 );
if( rc != SQLITE_OK )
{
mbstowcs( MsgTmpChar, sqlite3_errmsg( db ), strlen(
sqlite3_errmsg( db ) ) );
wsprintf( MsgChar, _T( "SQL error: %s\n" ), MsgTmpChar );
MessageBox( MsgChar, _T( "Error Info" ), MB_OK );
sqlite3_free( sqlcmd );
sqlite3_close(db);
return false;
}
rc = sqlite3_step( stat );
if( rc != SQLITE_ROW )
{
mbstowcs( MsgTmpChar, sqlite3_errmsg( db ), strlen(
sqlite3_errmsg( db ) ) );
wsprintf( MsgChar, _T( "SQL error: %s\n" ), MsgTmpChar );
MessageBox( MsgChar, _T( "Error Info" ), MB_OK );
sqlite3_free( sqlcmd );
sqlite3_close(db);
return false;
}
else
{
const void *printdata = sqlite3_column_blob( stat, 2 );
length = sqlite3_column_bytes( stat, 2 );
memcpy( buffer, printdata, length );
buffer[ length ] = 0x00;
*len = length;
}
rc = sqlite3_finalize( stat );
if( rc != SQLITE_OK )
{
mbstowcs( MsgTmpChar, sqlite3_errmsg( db ), strlen(
sqlite3_errmsg( db ) ) );
wsprintf( MsgChar, _T( "SQL error: %s\n" ), MsgTmpChar );
MessageBox( MsgChar, _T( "Error Info" ), MB_OK );
sqlite3_free( sqlcmd );
sqlite3_close(db);
return false;
}
sqlite3_free( sqlcmd );
sqlite3_close(db);
return true;
}
WenYuan
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now.
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users