2 question about SQLite lazarus / 16-Databases ---------------------------------------------------------------------- free07 · 2012-11-22 15:10 Hi all, Using Free Pascal and XCode, i have two question : First one : Here is my code : Code: [Select]function TAccesBase.GetLibSequence(P_iSequence : integer; var P_sLibSequence : UnicodeString) : boolean; var l_bOk : boolean; {$IFDEF FPC}     l_sSQL : UnicodeString;     l_DB : TSQLite;     l_SL : Classes.TStringList; {$ENDIF} begin   l_bOk := false; P_sLibSequence := ''; {$IFDEF FPC}   try     l_SL := Classes.TStringList.create;     l_DB := TSQLite.Create(UnicodeString(pAB_sFileName)); l_sSQL := 'SELECT Libelle FROM Sequence WHERE IdSequence = ''' + IntToStr(P_iSequence) + '''';     l_bOk := l_DB.Query(l_sSQL, l_SL);     if l_bOk = true then       P_sLibSequence := l_SL.Text;   // the result is allways : 'Libelle Libx"     l_bOk := Length(P_sLibSequence) > 0;     freeandnil(l_DB);     freeandnil(l_SL); except     on E:Exception do     begin       ShowMessage(E.Message); l_bOk := false;     end;   end; {$ENDIF} Result := l_bOk; end; I get my libelle, every is ok except the string libelle is added before my libelle , why ? In fact, he added in first the name of the column, how can i get it without it ? 2nd Question : How can i get a blob contains a bitmap, i cannot used DB.Query to obtain it because the syntax is : DB.Query(sql : string, result : string)... Where can i find documentation about TSQLite ? Sorry it made 3 questions TIA ---------------------------------------------------------------------- Phil · 2012-11-23 16:58 I'm not aware of any documentation for the TSQLite class. Looking at the source code copyright it looks like some of the oldest code in FPC. And it is clunky to use at first. The query result is a TStringList. The first item is a comma-separated list of fields identifying the data returned. Each additional item in the TStringList is a comma-separated list of data - that is, each item indexed starting with 1 is data record. In your case, you're returning only a single item and a single record, so you don't need to parse either the field list or the data list. Just l_SL[1] is all you need. For multiple fields, use the ValueList procedure to do the parsing. I find it useful to use "object composition" to wrap a TSQLite object in a Pascal class. See the UnicodeDb.pas unit here for an example: http://web.fastermac.net/~MacPgmr/qxotica/QxoticaStatus.html Also, you don't need to use UnicodeString. FPC's SQLite units wrap the UTF8 functions in the SQLite library, not the UTF16 functions. You can store a bitmap as a hex string in the file and thus query it as a string. Thanks. -Phil ---------------------------------------------------------------------- free07 · 2012-11-23 17:33 Thanks Phil, Sorry i don't find UnicodeDb.pas ... Yes, in fact, i need a simple Free Pascal wrapper for the SQLite API. without configuration and component, just a class that can be used with SQLite Database. And with documentation :-) If anyone knows it ... TIA ---------------------------------------------------------------------- Phil · 2012-11-23 17:43 Quote from: free07 on November 23, 2012, 06:33:17 pm Sorry i don't find UnicodeDb.pas ... http://sourceforge.net/p/qxotica/code/6/tree/trunk/demos/Unicodum/pasc al_server/UnicodeDb.pas