When calling this code more than once (It's called on the change of a combobox), I'm getting the error "Operation not allowed when the object is open" on the second change and on the third onwards i'm getting "invalid pointer operation".
if loadfile.Database <> nil then
loadfile.Database.destroy;
Loadfile.Database := Tdatabase.create(CardSets.Text, false);
LoadFile.Database.create(CardSets.Text, false);
refreshlist;
The create code is just
DataSource :=
'Provider=Microsoft.Jet.OLEDB.4.0' +
';Data Source=' + Path +
';Jet OLEDB:Engine Type=5';
with MainWindow do
begin
ADOConnection.ConnectionString := Datasource;
ADOConnection.LoginPrompt := False;
end;
And refreshlist just updates a visual list of the data in the database.
I've looked at some similar stackoverflow questions but i am unable to see how the answers could help my problem.
Side question, When to use .Destroy or .Free? .Free in this case just gives a different error.
Thanks.
createtwice? - BlorgbeardFreeAndNil- neitherdestroynorfreeset the value to nil. - Blorgbeard