Easy to use memory dataset lazarus / 16-Databases ---------------------------------------------------------------------- aradeonas · 2016-02-26 09:01 Hi, I want a memory dataset like  VirtualTable and really I cant understand what are these bufdataset and memdataset  and wiki page as I cant make bufdataset works without a file. I want an easy to sue memory dataset without any file usage. ---------------------------------------------------------------------- Thaddy · 2016-02-26 09:36 You don't have to save to file or create a file as long as the database is open. Here's a simple example: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program memdbtest;{$apptype console}{$mode objfpc}uses  db,memds;var   MemDb:TMemDataset;begin MemDb:=TMemDataset.Create(nil); try   MemDb.FieldDefs.Add('NAME',ftString,20);   MemDb.CreateTable;   MemDb.Open;   MemDb.Append;   MemDb.FieldByName('NAME').Value:='Free';   MemDb.Post;   MemDb.Append;   MemDb.FieldByName('NAME').Value:='Pascal';   MemDb.Post;   MemDb.SaveToFile('MemDb.txt');  // as long you do not close, you don't have to save finally   MemDb.Close;   MemDb.Free; end;end. Note: example modified from the mailing list. http://lists.lazarus.fre epascal.org/pipermail/lazarus/2009-January/040684.html You can of course also SaveToStream / LoadFromStream; ---------------------------------------------------------------------- aradeonas · 2016-02-26 09:50 Thanks Thaddy, Another question: As in wiki is said BufDataset is a better choice but is it really and is it a choice for using as a memory dataset? ---------------------------------------------------------------------- aradeonas · 2016-02-26 10:01 I checked your code and it works but Codetools has problem with memds unit and also it will replace it with MemDataSet unit that has a different TMemDataset without CreateTable option. ---------------------------------------------------------------------- Thaddy · 2016-02-26 10:12 Dunno about how codetools would screw that up. It should not. Are you using the dreaded CodeTyphon? BufDataSet has a the wiki explains some more possibiliities like custom filters, autoincrement data type and the Locate method. If you need those (at the cost of a little more memory pressure, but not much) by all means use BufDataSet. Here's a BufDataset example. Basically, you would call CreateDataSet instead of CreateTable. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program bufdbtest;{$apptype console}{$mode objfpc}uses  db,BufDataset;var  BufDb:TBufDataset;begin BufDb:=TBufDataset.Create(nil); try   BufDb.FieldDefs.Add('NAME',ftString,20);   BufDb.CreateDataSet;   BufDb.Open;   BufDb.Append;   BufDb.FieldByName('NAME').Value:='Free';   BufDb.Post;   BufDb.Append;   BufDb.FieldByName('NAME').Value:='Pascal';   BufDb.Post;   BufDb.SaveToFile('BufDb.txt'); finally   BufDb.Close;   BufDb.Free; end;end. ---------------------------------------------------------------------- aradeonas · 2016-02-26 10:22 Its interesting and your works good but my tests with a component made in IDE not in code and playing with options lead to this error : QuoteMissing (compatible) underlying dataset, can not openI dont know the reason but making a new component even in IDE without changing any property and do the stuff in the code make it work. Thanks. ---------------------------------------------------------------------- Thaddy · 2016-02-26 10:38 Here's simple code to get you started. You wil have to add the db unit to the uses clause.: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1;{$mode objfpc}{$H+}interfaceuses  Classes, SysUtils, BufDataset, Db, FileUtil, Forms, Controls, Graphics,  Dialogs, DbCtrls, DBGrids;  // I had to manually add the db unit to the uses clause... tdk.type   { TForm1 }   TForm1 = class(TForm)    BufDataset1: TBufDataset;    DataSource1: TDataSource;    DBEdit1: TDBEdit;    DBGrid1: TDBGrid;  DBNavigator1: TDBNavigator;    procedure FormCreate(Sender: TObject);    procedure FormDestroy(Sender: TObject);  private    { private declarations }  public    { public declarations }  end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.FormCreate(Sender: TObject);begin  BufDataSet1.FieldDefs.Add('NAME',ftString,20);  BufDataSet1.CreateDataset;  BufDataSet1.Open;end; procedure TForm1.FormDestroy(Sender: TObject);begin  BufDataSet1.Close;end; end.   Put a DataSource, a DbNavigator, a DbEdit and a BufDatasource on the form and set the datasource and dataset properties. That's all. ---------------------------------------------------------------------- aradeonas · 2016-02-26 10:42 Thanks I did the same and it works but my problem was a TBufDataset that I made changes in propeties and it makes it crash but without any changes as you showed it works. Thank you Thaddy. ---------------------------------------------------------------------- Thaddy · 2016-02-26 10:47 Quote from: aradeonas on February 26, 2016, 11:42:06 amThanks I did the same and it works but my problem was a TBufDataset that I made changes in propeties and it makes it crash but without any changes as you showed it works. Thank you Thaddy. Have a look at my by now modified example. It works. Don't activate the dataset through the designer first time. Wait. I created the fielddefs in code. ---------------------------------------------------------------------- mangakissa · 2016-02-26 10:56 With Virtualtable you can assign from another dataset.  Bufdataset can't (even tried it with loadfromstream). Still strange, because TSQLQuery is an inheritence of TBufDataset. Memdataset can do this, but what Thaddy says, it's less powerfull than Bufdataset. Hopefully in the future bufdataset will be equivalent with virtualtable ---------------------------------------------------------------------- Thaddy · 2016-02-29 05:32 This may also be of interest for submitter: https://www.sqlite.org/inmemorydb.html It works with Lazarus! ---------------------------------------------------------------------- aradeonas · 2016-02-29 05:58 Good point Thaddy, its useful but I should investigate more about how assign from another dataset with Bufdataset because it is moreeasy to use. ---------------------------------------------------------------------- cdbc · 2016-02-29 09:35 Hi Why don't you implement the "CopyFromDataset" method yourself, in TBufDataset from TMemDataset and then send the patch to the community, it doesn't look too hard  Regards Benny ---------------------------------------------------------------------- aradeonas · 2016-02-29 09:59 Yes you are right and as I said I will investigate more about it. ---------------------------------------------------------------------- Thaddy · 2016-02-29 10:09 Well. I am looking into the fact that the memdataset can do things that the bufdataset can't do. There is an obvious design flaw considering the inheritance. It may be the case that we have to move some code from one to the other. Mmmm, where's BigChimp when you need him ---------------------------------------------------------------------- cdbc · 2016-02-29 14:46 Hi Cool, while you're at it, have a look at "Locate" in TDbf  I've implemented my own cliendataset with delta and delayed updates, but I just needed support for SQLite backend.... Regards Benny ---------------------------------------------------------------------- aradeonas · 2016-02-29 19:19 I add this procedures to TBufDataset but I cant compile its package and Lazarus still uses old one,how can I compile it to use new changes? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i     procedure Clear;    Procedure CopyFromDataset(DataSet : TDataSet;CopyData : Boolean=True);Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure T CustomBufDataset.Clear;begin ClearIndexes; ClearBuffers; ClearFields;e nd; procedure TCustomBufDataset.CopyFromDataset(DataSet: TDataSet; CopyData: Boolean);Var  I  : Integer;  F,F1,F2 : TField;  L1,L2  : TList;  N : String;  OriginalPosition: TBookMark;begin Clear; For I:=0 to Dataset.FieldCount-1 do   begin   F:=Dataset.Fields[I];   TFieldDef .Create(FieldDefs,F.FieldName,F.DataType,F.Size,F.Required,F.FieldNo);  end; CreateDataset;   If CopyData then  begin    Open;    L1:=TList.Create;    Try      L2:=TList.Create;      Try        For I:=0 to FieldDefs.Count-1 do          begin          N:=FieldDefs[I].Name;          F1:=FieldByName(N);          F2:=DataSet.FieldByName(N);          L1.Add(F1);          L2.Add(F2);          end;        DisableControls;        Dataset.DisableControls;      OriginalPosition:=Dataset.GetBookmark;        Try          Dataset.Open;          Dataset.First;          While not Dataset.EOF do            begin            Append;            For I:=0 to L1.Count-1 do              begin              F1:=TField(L1[i]);            F2:=TField(L2[I]);              Case F1.DataType of              ftFixedChar,                ftString   : F1.AsString:=F2.AsString;                ftBoolean  : F1.AsBoolean:=F2.AsBoolean;                ftFloat    : F1.AsFloat:=F2.AsFloat;                ftLargeInt : F1.AsInteger:=F2.AsInteger;                ftSmallInt : F1.AsInteger:=F2.AsInteger;                ftInteger  : F1.AsInteger:=F2.AsInteger;                ftDate     : F1.AsDateTime:=F2.AsDateTime;                ftTime     : F1.AsDateTime:=F2.AsDateTime;                ftDateTime : F1.AsDateTime:=F2.AsDateTime;                else         F1.AsString:=F2.AsString;              end;              end;          Try              Post;            except              Cancel;            Raise;            end;            Dataset.Next;            end;        Finally          DataSet.GotoBookmark(OriginalPosition); //Return to original record          Dataset.EnableControls;          EnableControls;        end;      finally        L2.Free;      end;    finally      l1.Free;    end;  end;end; ---------------------------------------------------------------------- balazsszekely · 2016-02-29 19:45 QuoteI add this procedures to TBufDataset but I cant compile its package and Lazarus still uses old one,how can I compile it to use new changes?Bufdataset is a FPC unit, for the changes to take effect you need to recompile FPC. ---------------------------------------------------------------------- Thaddy · 2016-02-29 20:05 The code looks good. Why not submit it as a patch? ---------------------------------------------------------------------- aradeonas · 2016-02-29 20:34 Quote from: GetMem on February 29, 2016, 08:45:50 pmQuoteI add this procedures to TBufDataset but I cant compile its package and Lazarus still uses old one,how can I compile it to use new changes?Bufdataset is a FPC unit, for the changes to take effect you need to recompile FPC. How?I try what I found but keep getting weird errors. What should I do if I want to debug it?I never done that. ---------------------------------------------------------------------- aradeonas · 2016-02-29 20:42 Quote from: Thaddy on February 29, 2016, 09:05:09 pmThe code looks good. Why not submit it as a patch? Honestly I dont know how and one of the problems was getting and keep Lazarus trunk version OK in my computer, I discussed my problems in another topic. ---------------------------------------------------------------------- balazsszekely · 2016-02-29 20:44 @aradeonas http://forum.lazarus.freepascal.org/index.php/topic,29547.0.html ---------------------------------------------------------------------- aradeonas · 2016-02-29 20:49 @GetMem I read it but I still cant compile it. I give it another try ---------------------------------------------------------------------- Thaddy · 2016-02-29 20:53 Quote from: aradeonas on February 29, 2016, 09:42:17 pmQuote from: Thaddy on February 29, 2016, 09:05:09 pmThe code looks good. Why not submit it as a patch? Honestly I dont know how and one of the problems was getting and keep Lazarus trunk version OK in my computer, I discussed my problems in another topic. I can likely turn it into a patch that you can submit. ---------------------------------------------------------------------- aradeonas · 2016-02-29 20:57 QuoteI can likely turn it into a patch that you can submit.It will be very good. Thanks. Im still trying to compile and check it my self. ---------------------------------------------------------------------- balazsszekely · 2016-02-29 21:08 What about this? You can run a few tests without recompile: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i type  TBufDatasetHelper = class helper for TCustomBufDataset  private    procedure Clear;    procedure CopyFromDataset(DataSet: TDataSet; CopyData: Boolean);  end; procedure TBufDatasetHelper.Clear;begin  ClearIndexes;  ClearBuffers;  ClearFields;end; procedure TBufDatasetHelper.CopyFromDataset(DataSet: TDataSet; CopyData: Boolean);Var  I  : Integer;  F,F1,F2 : TField;  L1,L2  : TList;  N : String;  OriginalPosition: TBookMark;begin Clear; For I:=0 to Dataset.FieldCount-1 do   begin   F:=Dataset.Fields[I];   TFieldDef.Cr eate(FieldDefs,F.FieldName,F.DataType,F.Size,F.Required,F.FieldNo);   end; CreateDataset;   If CopyData then  begin    Open;    L1:=TList.Create;    Try      L2:=TList.Create;      Try        For I:=0 to FieldDefs.Count-1 do          begin          N:=FieldDefs[I].Name;          F1:=FieldByName(N);          F2:=DataSet.FieldByName(N);          L1.Add(F1);          L2.Add(F2);          end;        DisableControls;        Dataset.DisableControls;      OriginalPosition:=Dataset.GetBookmark;        Try          Dataset.Open;          Dataset.First;          While not Dataset.EOF do            begin            Append;            For I:=0 to L1.Count-1 do              begin              F1:=TField(L1[i]);            F2:=TField(L2[I]);              Case F1.DataType of              ftFixedChar,                ftString   : F1.AsString:=F2.AsString;                ftBoolean  : F1.AsBoolean:=F2.AsBoolean;                ftFloat    : F1.AsFloat:=F2.AsFloat;                ftLargeInt : F1.AsInteger:=F2.AsInteger;                ftSmallInt : F1.AsInteger:=F2.AsInteger;                ftInteger  : F1.AsInteger:=F2.AsInteger;                ftDate     : F1.AsDateTime:=F2.AsDateTime;                ftTime     : F1.AsDateTime:=F2.AsDateTime;                ftDateTime : F1.AsDateTime:=F2.AsDateTime;                else         F1.AsString:=F2.AsString;              end;              end;          Try              Post;            except              Cancel;            Raise;            end;            Dataset.Next;            end;        Finally          DataSet.GotoBookmark(OriginalPosition); //Return to original record          Dataset.EnableControls;          EnableControls;        end;      finally        L2.Free;      end;    finally      l1.Free;    end;  end;end;          //...var  BufDataset: TBufDataset;begin  BufDataset := TBufDataset.Create(nil);  BufDataset.CopyFromDataset();end; ---------------------------------------------------------------------- aradeonas · 2016-02-29 21:17 I tried to recompile but I give this error: QuoteC:\lazarus\fpc\3.0.0\source\packages\fcl- db>C:\lazarus\fpc\3.0.0\bin\i386-win32\make.exe  clean all install INSTALL_PREFIX="C:\lazarus\fpc\3.0.0" make: Nothing to be done for `clean'. C:/lazarus/fpc/3.0.0/bin/i386-win32/ppc386.exe fpmake.pp -n -Fu../../rtl -Fu../../packages/paszlib -Fu../../packages/fcl-process -Fu../../packages/hash -Fu../../packages/libtar -Fu../../packages/fpmkunit Fatal: Can't find unit system used by fpmake Fatal: Compilation aborted make: *** [fpmake.exe] Error 1Also I tried to see if it can find fpc.cfg and it seems it can. for thsi I tried fpc.exe -va command . ---------------------------------------------------------------------- balazsszekely · 2016-02-29 21:29 Quote@aradeonas I tried to recompile but I give this error. It works fine at my side. Did you try the class helper solution? ---------------------------------------------------------------------- aradeonas · 2016-02-29 21:31 Good call @GetMem. I wanted to do that but recompiling dpc distract me. Thanks to you I test it and add First to it and now it seems working good enough. I just dont like its memory usage. it takes about triple of simple query that I just copy if its a problem its about TBufDataset and I will look at it. Here the changed code : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var  I: integer;  F, F1, F2: TField;  L1, L2: TList;  N: string;  OriginalPosition: TBookMark;begin  Clear;  for I := 0 to Dataset.FieldCount - 1 do  begin    F := Dataset.Fields[I];    TFieldDef.Create(FieldDefs, F.FieldName, F.DataType, F.Size, F.Required, F.FieldNo);  end;  CreateDataset;  if CopyData then  begin    Open;    L1 := TList.Create;    try      L2 := TList.Create;      try        for I := 0 to FieldDefs.Count - 1 do        begin        N := FieldDefs[I].Name;          F1 := FieldByName(N);          F2 := DataSet.FieldByName(N);          L1.Add(F1);          L2.Add(F2);      end;        DisableControls;        Dataset.DisableControls;      OriginalPosition := Dataset.GetBookmark;        try          Dataset.Open;          Dataset.First;          while not Dataset.EOF do          begin            Append;            for I := 0 to L1.Count - 1 do            begin              F1 := TField(L1[i]);            F2 := TField(L2[I]);              case F1.DataType of                ftFixedChar,                ftString: F1.AsString := F2.AsString;              ftBoolean: F1.AsBoolean := F2.AsBoolean;                ftFloat: F1.AsFloat := F2.AsFloat;                ftLargeInt: F1.AsInteger := F2.AsInteger;                ftSmallInt: F1.AsInteger := F2.AsInteger;                ftInteger: F1.AsInteger := F2.AsInteger;                ftDate: F1.AsDateTime := F2.AsDateTime;              ftTime: F1.AsDateTime := F2.AsDateTime;                ftDateTime: F1.AsDateTime := F2.AsDateTime;                else                F1.AsString := F2.AsString;              end;            end;            try              Post;            except              Cancel;              raise;            end;            Dataset.Next;        end;        finally          DataSet.GotoBookmark(OriginalPosition); //Return to original record        Dataset.EnableControls;          EnableControls;        end;    finally        L2.Free;      end;    finally      l1.Free;    end;  First;  end;end; ---------------------------------------------------------------------- JuhaManninen · 2016-02-29 21:31 Quote from: aradeonas on February 29, 2016, 09:57:59 pmQuoteI can likely turn it into a patch that you can submit.It will be very good. Thanks. Im still trying to compile and check it my self. Oh, you should really learn to make patches yourself. Besides, it is extremely easy. Just one "svn diff" command or in TortoiseSVN "Create patch". Doesn't get much simpler. I understood you are making code for the online package manager. Then you surely must create patches. BTW, what problems you had with Lazarus trunk version in your computer? Where was it discussed? ---------------------------------------------------------------------- aradeonas · 2016-02-29 21:39 QuoteOh, you should really learn to make patches yourself. Besides, it is extremely easy. Just one "svn diff" command or in TortoiseSVN "Create patch". Doesn't get much simpler. I understood you are making code for the online package manager. Then you surely must create patches. BTW, what problems you had with Lazarus trunk version in your computer? Where was it discussed?I used TortoiseSVN but because I for a while I couldn't have my own Lazarus and FPC trunk from SVN I couldn't check making patches. I tired many times to get it and compile it from SVN as Wiki said but it will always cancel between it works maybe because of SF limits. I tried fpcup as I talked here about it and in my new Win10 machine it always fail recently : http://forum.lazarus.freepascal.org/index.php/topic,30386.0.html Mostly Im using GetLazarus version for checking last version. ---------------------------------------------------------------------- balazsszekely · 2016-02-29 21:39 @JuhaManninen Now that you mentioned...is there any progress with the online package manager,  because now I'm working on a task(not related to Lazarus IDE), which will download zip files from a web page. Info about zip files are stored in XML file. Pretty similar to the online manager requirements I guess. ---------------------------------------------------------------------- aradeonas · 2016-02-29 21:43 @JuhaManninen and @GetMem Yes I worked on it but for the time I gave up because its hard for me to understand Lazarus and FPC packages system and choose the best way for them as I dont know their best (although I checked all you mentioned in our mails) so I postpone it for another time when I have enough patient to understand it fully or help someone else if anyone brings it up again. But I like working on package managing parts,interface and,DB and it's website. ---------------------------------------------------------------------- aradeonas · 2016-02-29 21:47 Quote from: cdbc on February 29, 2016, 03:46:11 pmHi Cool, while you're at it, have a look at "Locate" in TDbf  I've implemented my own cliendataset with delta and delayed updates, but I just needed support for SQLite backend.... Regards Benny Can you explain your problem a little more? ---------------------------------------------------------------------- aradeonas · 2016-02-29 21:48 @JuhaManninen Here is another topic I talked about my PFC trunk problem : http://forum.lazarus.freepascal.org/index.php?topic=29258.20 ---------------------------------------------------------------------- balazsszekely · 2016-02-29 21:49 In my opinion the FPC package system is too complicated(nice clean code, but too many features). We need something simpler for Lazarus. Download the zip form remote site, extract to components folder, check for conflicts, dependency then install. ---------------------------------------------------------------------- aradeonas · 2016-02-29 22:00 Quote from: GetMem on February 29, 2016, 10:49:50 pmIn my opinion the FPC package system is too complicated(nice clean code, but too many features). We need something simpler for Lazarus. Download the zip form remote site, extract to components folder, check for conflicts, dependency then install. Its not a good place for dicuss it but many features is not problem, it just need someone who know the system and help it that part. Such service has many parts : -Installing and controlling packages and versions. -Mange and control packages in server and client -User interface -Website -Database as we discussed that being full dependent on services like Github or SF is not the best idea. It almost clear for me what to do for each part except the first part that is a mystery for me until now. ---------------------------------------------------------------------- JuhaManninen · 2016-02-29 22:30 Quote from: aradeonas on February 29, 2016, 10:43:46 pmYes I worked on it but for the time I gave up because its hard for me to understand Lazarus and FPC packages system ... Yes, I kind of guessed. Last autumn you were very enthusiastic and told me NOT to start implementing it to avoid duplicate effort. But yes, I understand. Anyway, there was a long thread in Lazarus mailing list starting 8 of August 2015 titled "An online package manager". If you guys want to discuss it more now, please open a new thread. I am planning (again) to study the topic soon ... Quote from: aradeonas on February 29, 2016, 10:39:06 pmI used TortoiseSVN but because I for a while I couldn't have my own Lazarus and FPC trunk from SVN I couldn't check making patches. aradeonas, you do NOT need FPC trunk for Lazarus trunk. I don't know where that misconception has come from. QuoteI tired many times to get it and compile it from SVN as Wiki said but it will always cancel between it works maybe because of SF limits. You try to do something fancy. Getting Lazarus is just one "svn co" command, and later "svn up". Then "make". QuoteI tried fpcup as I talked here about it and in my new Win10 machine it always fail recently : ... Don't use fpcup then! Why you want to turn a simple thing into a complicated thing? ---------------------------------------------------------------------- aradeonas · 2016-02-29 22:37 QuoteLast autumn you were very enthusiastic and told me NOT to start implementing it to avoid duplicate effort.To be fair I didnt say do NOT to implement it I just wanted to know if you working or now to prevent duplicate effort. But you are right, sorry for letting you down not every body are good at developing an IDE in daily routine. Quoteyou do NOT need FPC trunk for Lazarus trunk. I don't know where that misconception has come from.I know about that but I used to get that for checking purpose. QuoteDon't use fpcup then! Why you want to turn a simple thing into a complicated thing?Because I couldn't done the simpler way and before this problem I always used fpcup successfully QuoteYou try to do something fancy. Getting Lazarus is just one "svn co" command, and later "svn up". Then "make".Thanks for the help, I will try again. @Thaddy if you can pleas make a patch for now until I can make a working FPC trunk. ---------------------------------------------------------------------- JuhaManninen · 2016-02-29 23:03 Quote from: aradeonas on February 29, 2016, 11:37:56 pmBut you are right, sorry for letting you down not every body are good at developing an IDE in daily routine. Don't worry, you did not let anybody down. It is good to see enthusiastic people. ---------------------------------------------------------------------- Thaddy · 2016-03-01 05:45 Quote from: aradeonas on February 29, 2016, 11:37:56 pm@Thaddy if you can pleas make a patch for now until I can make a working FPC trunk. I will review - some more - test, create a patch and enter it in mantis with reference that it is your work sometime today. [edit] Patch submitted with small example here: http://bugs.freepascal.org/view.php?id=29761 ---------------------------------------------------------------------- aradeonas · 2016-03-01 07:39 Thank you very much Thaddy. ---------------------------------------------------------------------- Thaddy · 2016-03-01 07:57 @Aradeonas: http://freepascal.thaddy.com/fpctrunk-33140-dbpatch.zip Contains a prebuilt fpc trunk for win32, win64 and cross-compilers for linux i386, linux64 and armhf to test your code. Make sure you set the paths correctly! It is FPC only, no Lazarus, sorry. ---------------------------------------------------------------------- aradeonas · 2016-03-01 11:31 Thank you very much Thaddy  Now with your and others helps I have last trunk FPC and Lazarus and made a test patch and it seems ok. But how can I debug this unit? ---------------------------------------------------------------------- Thaddy · 2016-03-01 11:59 send me an email. I will make a debug build for you and provide you with a separate link. The link is a release build. ---------------------------------------------------------------------- aradeonas · 2016-03-01 12:04 Quote from: Thaddy on March 01, 2016, 12:59:02 pmsend me an email. I will make a debug build for you and provide you with a separate link. The link is a release build. Thanks but I dont have your email and also now I have my own working FPC trunk and happily compile it but it is in release mode, how can I make it for a debug mode? ---------------------------------------------------------------------- Thaddy · 2016-03-01 12:11 You really need a debug build for that, or recompile the code with debug information. My email is easy to find. It is the first name of the owner at the website without the subdomain I mentioned in my previous link. Now, you are not a bot are you So there you go.... And the website itself is the first name of the owner. Just repeat. ---------------------------------------------------------------------- aradeonas · 2016-03-01 12:23 QuoteYou really need a debug build for that, or recompile the code with debug information.Yes and I want to compile it with debug information but how? QuoteMy email is easy to find. It is the first name of the owner at the website without the subdomain I mentioned in my previous link. Now, you are not a bot are you So there you go.... And the website itself is the first name of the owner. Just repeat.OK  I mailed you if I wasn't wrong . ---------------------------------------------------------------------- Thaddy · 2016-03-01 14:02 Look at your email. We can discuss. ---------------------------------------------------------------------- esvignolo · 2016-03-02 19:01 hi! a little correction for Null values: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Try        Dataset.Open;          Dataset.First;          While not Dataset.EOF do            begin                Append;                For I:=0 to L1.Count-1 do                  begin                      F1:=TField(L1[i]);                      F2:=TField(L2[I]);                    if not F2.IsNull then //HERE                      Case F1.DataType of                        ftFixedChar,                      ftString   : F1.AsString:=F2.AsString;                        ftBoolean  : F1.AsBoolean:=F2.AsBoolean;                        ftFloat    : F1.AsFloat:=F2.AsFloat;                        ftLargeInt : F1.AsInteger:=F2.AsInteger;                        ftSmallInt : F1.AsInteger:=F2.AsInteger;                        ftInteger  : F1.AsInteger:=F2.AsInteger;                        ftDate     : F1.AsDateTime:=F2.AsDateTime;                        ftTime     : F1.AsDateTime:=F2.AsDateTime;                        ftDateTime : F1.AsDateTime:=F2.AsDateTime;                        ftMemo     : F1.AsString:=F2.AsString;                        else         F1.AsString:=F2.AsString;                  end                  else                     F1.Value:=NULL; //AND HERE               end;          Try              Post;            except              Cancel;            Raise;            end;            Dataset.Next;            end;        Finally          DataSet.GotoBookmark(OriginalPosition); //Return to original record          Dataset.EnableControls;          EnableControls;        end; Quote from: aradeonas on February 29, 2016, 10:31:17 pmGood call @GetMem. I wanted to do that but recompiling dpc distract me. Thanks to you I test it and add First to it and now it seems working good enough. I just dont like its memory usage. it takes about triple of simple query that I just copy if its a problem its about TBufDataset and I will look at it. Here the changed code : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var  I: integer;  F, F1, F2: TField;  L1, L2: TList;  N: string;  OriginalPosition: TBookMark;begin  Clear;  for I := 0 to Dataset.FieldCount - 1 do  begin    F := Dataset.Fields[I];    TFieldDef.Create(FieldDefs, F.FieldName, F.DataType, F.Size, F.Required, F.FieldNo);  end;  CreateDataset;  if CopyData then  begin    Open;    L1 := TList.Create;    try      L2 := TList.Create;      try        for I := 0 to FieldDefs.Count - 1 do        begin        N := FieldDefs[I].Name;          F1 := FieldByName(N);          F2 := DataSet.FieldByName(N);          L1.Add(F1);          L2.Add(F2);      end;        DisableControls;        Dataset.DisableControls;      OriginalPosition := Dataset.GetBookmark;        try          Dataset.Open;          Dataset.First;          while not Dataset.EOF do          begin            Append;            for I := 0 to L1.Count - 1 do            begin              F1 := TField(L1[i]);            F2 := TField(L2[I]);              case F1.DataType of                ftFixedChar,                ftString: F1.AsString := F2.AsString;              ftBoolean: F1.AsBoolean := F2.AsBoolean;                ftFloat: F1.AsFloat := F2.AsFloat;                ftLargeInt: F1.AsInteger := F2.AsInteger;                ftSmallInt: F1.AsInteger := F2.AsInteger;                ftInteger: F1.AsInteger := F2.AsInteger;                ftDate: F1.AsDateTime := F2.AsDateTime;              ftTime: F1.AsDateTime := F2.AsDateTime;                ftDateTime: F1.AsDateTime := F2.AsDateTime;                else                F1.AsString := F2.AsString;              end;            end;            try              Post;            except              Cancel;              raise;            end;            Dataset.Next;        end;        finally          DataSet.GotoBookmark(OriginalPosition); //Return to original record        Dataset.EnableControls;          EnableControls;        end;    finally        L2.Free;      end;    finally      l1.Free;    end;  First;  end;end; ---------------------------------------------------------------------- aradeonas · 2016-03-05 21:53 Thanks @esvignolo. Can any one help me to make a debug version of FPC to run more test on this code? Now I can compile trunk version but just release mode, how can I compile and debug this new code?