There is a table entry for mdb. And the table has 18 columns and 10 rows. I want to write the contents of the table in the ini file. Is there a way?
procedure TForm1.Button4Click(Sender: TObject);
var
ini : TIniFile;
i : Integer;
sTableInfo : String;
begin
Adotable1.First;
ini := TIniFile.Create('C:\Users\win10_pro\Desktop\test.ini');
sTableInfo := Adotable1['name'] + ' ' +Adotable1['capital']+ ' ' + Adotable1['continent'];
try
for i := 0 to adotable1.RecordCount - 1 do
begin
ini.WriteString('Name', 'test1', sTableInfo );
end;
ShowMessage('INI file create');
end;
finally
ini.Free;
end;
This way, only one item goes in, and I want all items to go in. This way, only one item goes in, and I want all items to go in.
I have no idea why you want to do this, since you have a perfectly good database that is already storing the data. However, this should do what you want (untested). Note I also had to change the code that writes to the INI file so that the key changes with every pass, or only one value is written.
procedure TForm1.Button4Click(Sender: TObject);
var
ini : TIniFile;
keyNo: Integer;
sTableInfo : String;
begin
Adotable1.First;
ini := TIniFile.Create('C:\Users\win10_pro\Desktop\test.ini');
keyNo := 1;
try
while not adotable1.Eof do
begin
sTableInfo := Adotable1['name'] + ' ' +Adotable1['capital']+ ' ' + Adotable1['continent'];
ini.WriteString('Name', 'test' + IntToStr(keyNo), sTableInfo );
Inc(keyNo);
adoTable1.Next;
end;
ShowMessage('INI file created');
finally
ini.Free;
end;
end;