Hi
I have what I suspect an easy to solve issue, but I am struggling.
I have a DBGrid component that is shown after two seperate functions have been run.
The first function goes through a load of files and outputs the filenames and some other values to ColumnA and ColumnB of an SQLIte table.
The second function goes through another load of files from a different folder and outputs the filenames and some other values of those files to the same SQLite table. During each function, the values are written to the SQLIte database and then when both have finished, DBGrid is made visible. The problem is, the values from the second function are put in rows below the first insertions for obvious and logical reasons. But I want the second function to put its values in Columns C, Row 1, and Columns D, Row 1, and then onto Row 2 etc starting at Row1, instead of carrying on in Columns A and B, starting from the last used row. So I want to produce a table like that seen below :
Value A Value B Value C Value D
Filename1 xyz Filename3 ghj
Filename2 kkk Filename4 ert
However, what I am getting in DBGrid with the pseudo code below is this kind of display :
Value A Value B
Filename1 xyz
Filename2 kkk
Filename3 ghj
Filename4 ert
// FunctionA runs through a stringlist of filenames first, and inserts values about the files into SQLite DB
FunctionA
var
ValB : string;
begin
for i := 0 to slFileListA.Count -1 do
begin
ValB := FunctionX(slFileListA.Strings[i]);
frmSQLiteDBases.WriteToDatabase(slFileListA.Strings[i], ValB);
...
end;
// FunctionB runs second using a second stringlist of filenames, and inserts values about the files into SQLite DB
FunctionB
var
ValD : string;
begin
for i := 0 to slFileListB.Count -1 do
begin
ValD := FunctionX(slFileListB.Strings[i]);
frmSQLiteDBases.WriteToDatabase(slFileListB.Strings[i], ValD);
...
end;
// This is what inserts the values into SQLite, passing Filename from SL as Val1, and some other data as Val2
procedure TfrmSQLiteDBases.WriteToDatabase(Val1, Val2 : string);
begin
try
sqlCOMPARETWOFOLDERS.Close;
sqlCOMPARETWOFOLDERS.SQL.Text := 'INSERT into TBL_COMPARE_TWO_FOLDERS (DBColumn1, DBColumn2) values (:Val1,:Val2)';
SQLTransaction1.Active := True;
sqlCOMPARETWOFOLDERS.Params.ParamByName('DBColumn1').AsString := Val1;
sqlCOMPARETWOFOLDERS.Params.ParamByName('DBColumn2').AsString := Val2;
sqlCOMPARETWOFOLDERS.ExecSQL;
except
on E: EDatabaseError do
begin
MessageDlg('Error','A database error has occurred. Technical error message: ' + E.Message,mtError,[mbOK],0);
end;
end;
end;
So is there a way to say "Put the value in ColumnX and Y starting at Row Z"?
Many thanks