SQLite connection inactive lazarus / 16-Databases ---------------------------------------------------------------------- SteveF · 2009-03-25 19:52 The following code uses TSQLite datasets to build & activate table in a SQLite file.  This is an altered version of the TSQLite dataset tutorial available at http://www.geocities.com/camara_luiz/docs/dataset/dataset- tutorial-01.html  It used to work – I have a version that will connect to the file built, and read & write to the tables inside. Then I foolishly made some changes to the application without saving off what was working before the change.  When I changed this back to what I thought they were before, I get the following error: Project AddressBook raised exception class ‘EdatabaseError’ with message: Operation cannon be performed on an inactive dataset. Obviously, I overlooked something.  Any assistance to get this thing going again without rebuilding from scratch will be appreciated. Here’s the code: =============== Procedure Tform1.Formcreate(Sender: Tobject); Begin     ForceDirectories(GetAppConfigDir(False));   With NamesDS do   begin    FileName := IncludeTrailingPathDelimiter(GetAppConfigDir(False)) + 'addressbook.db';    TableName := 'Names';    if not TableExists then    begin     FieldDefs.Clear;     FieldDefs.Add('NameID',ftAutoInc);     FieldDefs.Add('Fname',ftString);     FieldDefs.Add('Lname',ftString);     CreateTable;    end;    SQL := 'SELECT * FROM Names ORDER BY Lname, Fname;';    Open;   end;   With AddrDS do   begin    FileName := IncludeTrailingPathDelimiter(GetAppConfigDir(False)) + 'addressbook.db';    TableName := 'Addresses';    if not TableExists then    begin     FieldDefs.Clear;     FieldDefs.Add('AddrID',ftAutoInc);     FieldDefs.Add('NameID',ftInteger);     FieldDefs.Add('AddrType',ftString);     FieldDefs.Add('Company',ftString);     FieldDefs.Add('Address',ftString);     FieldDefs.Add('Town',ftString);     FieldDefs.Add('State',ftString);     FieldDefs.Add('ZIP',ftString);     FieldDefs.Add('Nation',ftString);     CreateTable;    end;    Open;   end;   With PhonesDS do   begin    FileName := IncludeTrailingPathDelimiter(GetAppConfigDir(False)) + 'addressbook.db';    TableName := 'Phones';    if not TableExists then    begin     FieldDefs.Clear;     FieldDefs.Add('PhoneID',ftAutoInc);     FieldDefs.Add('NameID',ftInteger);     FieldDefs.Add('PhoneType',ftString);     FieldDefs.Add('Number',ftString);     CreateTable;    end;    Open;   end;   With wwwDS do   begin    FileName := IncludeTrailingPathDelimiter(GetAppConfigDir(False)) + 'addressbook.db';    TableName := 'WWW';    if not TableExists then    begin     FieldDefs.Clear;     FieldDefs.Add('wwwID',ftAutoInc);     FieldDefs.Add('NameID',ftInteger);     FieldDefs.Add('wwwType',ftString);     FieldDefs.Add('wwwData',ftString);     CreateTable;    end;    Open;   end; End; =============== TIA, Steve ---------------------------------------------------------------------- Loesje · 2009-03-27 13:05 Try to find out on which line the problem occurs. ---------------------------------------------------------------------- SteveF · 2009-03-28 20:17 I will see if I can identify the specific line; the problem is that the application compiles successfully without errors, but the application does not display data that I know is present in the SQLite tables (and displays in the "old" version that was built before I tried to "improve" it.   When I click a button on the form to add a new record to the (main) names table, I receive the error message quoted above. Steve ---------------------------------------------------------------------- LuizAmérico · 2009-03-29 19:46 To know why the data is wrong, retrieve the value of GetAppConfigDir(False) (Hint/Quick Hack: set it to the Caption property) and see if the file that resides there is what you are expecting. Replace by the correct version if is the case. BTW: changing the executable name also changes this directory. The error after pressing the button is caused because the Dataset is not open. Get the name of the dataset inside the Button handler and see if is open in the Form.OnCreate handler or if is closed elsewhere.