dbf data read/ write to table lazarus / 63-Database ---------------------------------------------------------------------- draggon · 2016-02-29 09:10 not clear how to read/ write data to the *.dbf table from within application. Makes sense ODBC connection? Enable sODBC using SQL? Thank you ---------------------------------------------------------------------- Thaddy · 2016-02-29 09:26 Quote from: draggon on February 29, 2016, 10:10:46 amnot clear how to read/ write data to the *.dbf table from within application. Makes sense ODBC connection? Enable sODBC using SQL? Thank you You don't need ODBC. There are Lazarus native controls for dBase files. And SQL is inherently not supported for the dBase format. ---------------------------------------------------------------------- draggon · 2016-02-29 11:26 example would be highly appreciated ---------------------------------------------------------------------- draggon · 2016-02-29 12:43 I mean how to read/ write particular record/ field in the record. ---------------------------------------------------------------------- molly · 2016-02-29 12:51 Try this and see if that helps you. ---------------------------------------------------------------------- draggon · 2016-02-29 13:41 thanks Molly, I have this, unfortunately it does not solve my question. Good example would be to move data from an array to db table. ---------------------------------------------------------------------- molly · 2016-02-29 15:57 Quote from: draggon on February 29, 2016, 02:41:14 pm.. Good example would be to move data from an array to db table. No idea, why one would want to do that. Which is probably why there isn't such an example. Consider this a bad written example: Code: [Select]program test2; {$MODE OBJFPC}{$H+} uses   Heaptrc, Dbf, db, Dbf_Common, SysUtils;  Const   DBFileName = 'mydata.dbf'; var   MyDbf     : TDbf;   DataArray : Array of SmallInt; Procedure Create_Some_Array_Data; var   i : Integer; begin   SetLength(DataArray, 1000000);   for i := Low(DataArray) to High(dataArray) do     DataArray[i] := Random(65536) + 1 - (65536 shr 2); end; procedure Do_DBF_Stuff; var   i : Integer; begin   MyDbf := TDbf.Create(nil);   Try     if Not FileExists(DBFileName) then     begin       Writeln('creating DB');       MyDbf.TableLevel := 7;       MyDbf.Exclusive := True;       MyDbf.TableName := DBFileName;       with MyDbf.FieldDefs do       begin         Add('Number', ftinteger, 4, true);          End;       MyDbf.CreateTable;     end     else     begin       MyDbf.TableLevel := 7;       MyDbf.Exclusive := True;       MyDbf.TableName := DBFileName;     end;     // Write some array to the table     try       Writeln('Adding Data');       MyDBF.Open;       MyDBF.Last;       for i := Low(DataArray) to High(dataArray) do       begin         MyDBF.insert;         MyDBF.Fields.Fields[0].Value:= DataArray[i];         MyDBF.Post;       end;     finally       MyDBF.Close;     end;     // Read Some Array from the table        try          Writeln('Reading Data');       MyDBF.Open;             i := MyDBF.ExactRecordCount;       SetLength(DataArray, i);       i := Low(DataArray);       MyDBF.First;       while not MyDBF.EOF do       begin         DataArray[i] := MyDBF.Fields[0].AsInteger;         MyDBF.Next;         inc(i);       end;        finally       MyDBF.Close;     end;   finally     MyDbf.Free;   end; end; Begin   WriteLn('Creating array Data');   Create_Some_Array_Data;   WriteLn('Perform some DBF action -> Get yourself a cuppa tea');   Do_DBF_Stuff;   WriteLn('Done'); end. Strange, as i was able to find everything i used here from the wiki (except for one minor thing, but nothing a google search couldn't figure out).  So.... what's your excuse ?