[Solved]problem with locate on tsqlquery lazarus / 16-Databases ---------------------------------------------------------------------- nicola69 · 2013-02-04 11:55 Hi My lazarus version is 1.04 , fpc 2.6.0 , cpu icore 5 and my so is windows xp 32 bit. I use sqlite as db. I need copy my table on memory and search field on it. I write my application but when use locate of tsqlquery  for searching in a column it find wrong row of table. It find a row with a string that begin and i don't use loPartialKey as option I have attach my sqlite db . my unit example is unit Unit1; {$mode objfpc}{$H+} interface uses   Classes, SysUtils, sqlite3conn, sqldb, db, FileUtil, Forms, Controls,   Graphics, Dialogs, DBGrids, StdCtrls, DbCtrls; type   { TForm1 }   TForm1 = class(TForm)     Button1: TButton;     Datasource1: TDatasource;     DBGrid1: TDBGrid;     DBNavigator1: TDBNavigator;     SQLite3Connection1: TSQLite3Connection;     SQLQuery1: TSQLQuery;     SQLTransaction1: TSQLTransaction;     procedure Button1Click(Sender: TObject);   private     { private declarations }   public     { public declarations }   end; var   Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.Button1Click(Sender: TObject); begin   SQLQuery1.Locate('cod_age','FA0160',[]);  ShowMessage(IntToStr(SQLQuery1.RecNo)); end; end.                                               showmessage return 21 but correct row is 823 Someone could help me to understand why it doesn't work ? ---------------------------------------------------------------------- BigChimp · 2013-02-04 12:27 Thanks for posting the database and some code. Please upload a complete sample project so others can help you easier. Use e.g. menu  Project/Publish Project then zip up the result and attach it. Thanks. ---------------------------------------------------------------------- nicola69 · 2013-02-04 13:05 ok you can download my sample application on this link https://dl.dropbox.com/u/64726031/test%20sqlite.zip ---------------------------------------------------------------------- BigChimp · 2013-02-04 14:34 Thanks a lot. Edit: ok, I see the problem. ---------------------------------------------------------------------- BigChimp · 2013-02-04 14:52 This: Code: [Select]showmessage('size: '+inttostr(sqlquery1.fields.FieldByName('cod_age').Size));shows fpc thinks the field size is 5 which it is according to sqlite manager: Code: [Select]CREATE TABLE "anagrafica" ("id" INTEGER PRIMARY KEY  NOT NULL ,"cod_age" char(5),"regione" varchar(70),"provincia" varchar(70))... what happens if you change it to char(6) yes, you managed to squeeze in more data than you should... but I think that's an sqlite "feature" ) ---------------------------------------------------------------------- nicola69 · 2013-02-04 15:53 thank BigChimp i have made a mistake i have changed from char(5) to char(6) and now work. ---------------------------------------------------------------------- BigChimp · 2013-02-04 16:10 Great! Glad it works.