Hi
I've searched the forums here for problems using the OpenDialog control but nothing similar seems to have been posted before.
I've been asked to put together a file import app to get some info imported into a DBISAM DB which I'm progressing with, albeit slowly as I'm new to both Delphi and DBISAM (although not new to programming itself).
I have some code on the OnClick event of a button on my form that opens the OpenDialog dialog so the user can select the file to import - all works fine on the first click but if I click the button a second time it crashes out with an exception error (the error message says its trying to read a portion of memory - I don't have the exact message with me at the moment).
As I'm new to Delphi I just wanted to check I wasn't doing something dumb that's likely to cause this problem - the code for the OnClick is below:
Thanks a lot in advance
Martin
procedure TForm1.Button1Click(Sender: TObject);
begin
With DBISAMTable1 do
Begin
DatabaseName:='Memory';
TableName:='NewTable';
if not exists then
begin
with FieldDefs do
begin
Add('fDate',ftDate,0,True);
Add('fCost_Centre',ftString,50,False);
Add('fVehicleNum',ftString,50,False);
Add('fMileage',ftInteger,0,False);
Add('fCentre',ftString,50,False);
Add('fNotes',ftMemo,0,False);
end;
end;
createtable;
Active:=True;
end;
DBISAMDatabase1.Connected:=True;
{opendialog1.Options:=[ofNoChangeDir]; -- Added this line to see if it solved the problem, it doesn’t}
If opendialog1.execute then
Begin
QImport2XLS1.FileName:=opendialog1.FileName;
qimport2xls1.Execute;
qimport2xls1.Free;
{opendialog1.Files.Clear; -- Added this to see if it solved the problem, nope! }
opendialog1.Free;
end;
end;
I've searched the forums here for problems using the OpenDialog control but nothing similar seems to have been posted before.
I've been asked to put together a file import app to get some info imported into a DBISAM DB which I'm progressing with, albeit slowly as I'm new to both Delphi and DBISAM (although not new to programming itself).
I have some code on the OnClick event of a button on my form that opens the OpenDialog dialog so the user can select the file to import - all works fine on the first click but if I click the button a second time it crashes out with an exception error (the error message says its trying to read a portion of memory - I don't have the exact message with me at the moment).
As I'm new to Delphi I just wanted to check I wasn't doing something dumb that's likely to cause this problem - the code for the OnClick is below:
Thanks a lot in advance
Martin
procedure TForm1.Button1Click(Sender: TObject);
begin
With DBISAMTable1 do
Begin
DatabaseName:='Memory';
TableName:='NewTable';
if not exists then
begin
with FieldDefs do
begin
Add('fDate',ftDate,0,True);
Add('fCost_Centre',ftString,50,False);
Add('fVehicleNum',ftString,50,False);
Add('fMileage',ftInteger,0,False);
Add('fCentre',ftString,50,False);
Add('fNotes',ftMemo,0,False);
end;
end;
createtable;
Active:=True;
end;
DBISAMDatabase1.Connected:=True;
{opendialog1.Options:=[ofNoChangeDir]; -- Added this line to see if it solved the problem, it doesn’t}
If opendialog1.execute then
Begin
QImport2XLS1.FileName:=opendialog1.FileName;
qimport2xls1.Execute;
qimport2xls1.Free;
{opendialog1.Files.Clear; -- Added this to see if it solved the problem, nope! }
opendialog1.Free;
end;
end;