Recent

Author Topic: Firebird embedded error  (Read 307 times)

Raf20076

  • Full Member
  • ***
  • Posts: 183
    • https://github.com/Raf20076
Firebird embedded error
« on: February 18, 2025, 06:23:51 am »
Hi guys

I have a problem with firebird embedded. When I compile app I have got error

Code: Pascal  [Select][+][-]
  1. Project project1 raised exception class 'EDatabaseError' with message
  2. DataSource1: Circular datasource reference are not allowed

I tried everything and search the forum but I have no idea, what cause it.

My code is

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, DB, IBConnection, SQLDBLib, SQLDB, Forms,
  9.   Controls, Graphics, Dialogs, DBCtrls, DBGrids, StdCtrls;
  10.  
  11. type
  12.  
  13.   { TForm1 }
  14.  
  15.   TForm1 = class(TForm)
  16.     DataSource1: TDataSource;
  17.     DBGrid1: TDBGrid;
  18.     DBNavigator1: TDBNavigator;
  19.     IBConnection1: TIBConnection;
  20.     Label1: TLabel;
  21.     SQLDBLibraryLoader1: TSQLDBLibraryLoader;
  22.     SQLQuery1: TSQLQuery;
  23.     SQLTransaction1: TSQLTransaction;
  24.     procedure FormCreate(Sender: TObject);
  25.    
  26.   private
  27.  
  28.   public
  29.  
  30.   end;
  31.  
  32. var
  33.   Form1: TForm1;
  34.  
  35. implementation
  36.  
  37. {$R *.lfm}
  38.  
  39. { TForm1 }
  40.  
  41. procedure TForm1.FormCreate(Sender: TObject);
  42.  var
  43.   DataPath:AnsiString;
  44.   FirebirdPath: AnsiString;
  45. begin
  46.   DataSource1.DataSet := SQLQuery1;
  47.  
  48.   DataPath := ExtractFilePath(Application.ExeName) + 'data\employee.fdb'; // database
  49.   FirebirdPath := ExtractFilePath(Application.ExeName) + 'firebird\fbclient.dll'; // database
  50.  
  51.   SQLDBLibraryLoader1.ConnectionType:='Firebird';
  52.   SQLDBLibraryLoader1.LibraryName:=FirebirdPath;
  53.   SQLDBLibraryLoader1.Enabled:=True;
  54.  
  55.   IBConnection1.DatabaseName:=DataPath;
  56.   IBConnection1.Connected:=True;
  57.  
  58.  
  59.  
  60.   SQLQuery1.SQLConnection:=IBConnection1;
  61.   SQLQuery1.SQL.Text:='select RDB$Relation_Name from RDB$RELATIONS where RDB$Relation_Name not like ''%$%''';
  62.   SQLQuery1.Open;
  63.   SQLQuery1.Active:=True;
  64.   SQLTransaction1.DataBase:=IBConnection1;
  65.   SQLQuery1.Transaction:=SQLTransaction1;
  66.  
  67.  
  68.   DBNavigator1.DataSource := DataSource1;
  69.   DBGrid1.DataSource := DataSource1;
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77. end;
  78.  
  79.  
  80. end.
  81.  
  82.  

Thanks

Fenix0

  • Newbie
  • Posts: 1
Re: Firebird embedded error
« Reply #1 on: February 18, 2025, 07:29:06 am »
Hi guys

I have a problem with firebird embedded. When I compile app I have got error

Code: Pascal  [Select][+][-]
  1. Project project1 raised exception class 'EDatabaseError' with message
  2. DataSource1: Circular datasource reference are not allowed

I tried everything and search the forum but I have no idea, what cause it.

My code is

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, DB, IBConnection, SQLDBLib, SQLDB, Forms,
  9.   Controls, Graphics, Dialogs, DBCtrls, DBGrids, StdCtrls;
  10.  
  11. type
  12.  
  13.   { TForm1 }
  14.  
  15.   TForm1 = class(TForm)
  16.     DataSource1: TDataSource;
  17.     DBGrid1: TDBGrid;
  18.     DBNavigator1: TDBNavigator;
  19.     IBConnection1: TIBConnection;
  20.     Label1: TLabel;
  21.     SQLDBLibraryLoader1: TSQLDBLibraryLoader;
  22.     SQLQuery1: TSQLQuery;
  23.     SQLTransaction1: TSQLTransaction;
  24.     procedure FormCreate(Sender: TObject);
  25.    
  26.   private
  27.  
  28.   public
  29.  
  30.   end;
  31.  
  32. var
  33.   Form1: TForm1;
  34.  
  35. implementation
  36.  
  37. {$R *.lfm}
  38.  
  39. { TForm1 }
  40.  
  41. procedure TForm1.FormCreate(Sender: TObject);
  42.  var
  43.   DataPath:AnsiString;
  44.   FirebirdPath: AnsiString;
  45. begin
  46.   DataSource1.DataSet := SQLQuery1;
  47.  
  48.   DataPath := ExtractFilePath(Application.ExeName) + 'data\employee.fdb'; // database
  49.   FirebirdPath := ExtractFilePath(Application.ExeName) + 'firebird\fbclient.dll'; // database
  50.  
  51.   SQLDBLibraryLoader1.ConnectionType:='Firebird';
  52.   SQLDBLibraryLoader1.LibraryName:=FirebirdPath;
  53.   SQLDBLibraryLoader1.Enabled:=True;
  54.  
  55.   IBConnection1.DatabaseName:=DataPath;
  56.   IBConnection1.Connected:=True;
  57.  
  58.  
  59.  
  60.   SQLQuery1.SQLConnection:=IBConnection1;
  61.   SQLQuery1.SQL.Text:='select RDB$Relation_Name from RDB$RELATIONS where RDB$Relation_Name not like ''%$%''';
  62.   SQLQuery1.Open;
  63.   SQLQuery1.Active:=True;
  64.   SQLTransaction1.DataBase:=IBConnection1;
  65.   SQLQuery1.Transaction:=SQLTransaction1;
  66.  
  67.  
  68.   DBNavigator1.DataSource := DataSource1;
  69.   DBGrid1.DataSource := DataSource1;
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77. end;
  78.  
  79.  
  80. end.
  81.  
  82.  

Thanks
The issue is that you're assigning `DataSource1.DataSet := SQLQuery1` before setting it to `DBNavigator1` and `DBGrid1`. To fix it, just change the order:

```pascal
SQLQuery1.Open;
DataSource1.DataSet := SQLQuery1;  // Set DataSource after opening the query
DBNavigator1.DataSource := DataSource1;
DBGrid1.DataSource := DataSource1;
```

This should solve the circular reference error.

rvk

  • Hero Member
  • *****
  • Posts: 6693
Re: Firebird embedded error
« Reply #2 on: February 18, 2025, 07:41:05 am »
You created the components vis the ide.
You could set all the connections the.

BUT are you sure you didn't set SQLQuery1.Datasource to Datasource1 in the Object Inspector?
That would mean you create a circular reference with the line DataSource1.DataSet := SQLQuery1

Raf20076

  • Full Member
  • ***
  • Posts: 183
    • https://github.com/Raf20076
Re: Firebird embedded error
« Reply #3 on: February 18, 2025, 08:55:36 am »
You created the components vis the ide.
You could set all the connections the.

BUT are you sure you didn't set SQLQuery1.Datasource to Datasource1 in the Object Inspector?
That would mean you create a circular reference with the line DataSource1.DataSet := SQLQuery1


Yes it was this problem plus I change code as
Quote
The issue is that you're assigning `DataSource1.DataSet := SQLQuery1` before setting it to `DBNavigator1` and `DBGrid1`. To fix it, just change the order:

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, DB, IBConnection, SQLDBLib, SQLDB, Forms,
  9.   Controls, Graphics, Dialogs, DBCtrls, DBGrids, StdCtrls;
  10.  
  11. type
  12.  
  13.   { TForm1 }
  14.  
  15.   TForm1 = class(TForm)
  16.     DataSource1: TDataSource;
  17.     DBGrid1: TDBGrid;
  18.     DBNavigator1: TDBNavigator;
  19.     IBConnection1: TIBConnection;
  20.     Label1: TLabel;
  21.     SQLDBLibraryLoader1: TSQLDBLibraryLoader;
  22.     SQLQuery1: TSQLQuery;
  23.     SQLTransaction1: TSQLTransaction;
  24.     procedure FormCreate(Sender: TObject);
  25.  
  26.   private
  27.  
  28.   public
  29.  
  30.   end;
  31.  
  32. var
  33.   Form1: TForm1;
  34.  
  35. implementation
  36.  
  37. {$R *.lfm}
  38.  
  39. { TForm1 }
  40.  
  41. procedure TForm1.FormCreate(Sender: TObject);
  42.  var
  43.   DataPath:AnsiString;
  44.   FirebirdPath: AnsiString;
  45. begin
  46.  
  47.  
  48.   DataPath := ExtractFilePath(Application.ExeName) + 'data\employee.fdb'; // database
  49.   FirebirdPath := ExtractFilePath(Application.ExeName) + 'firebird\fbclient.dll'; // firebird dll's
  50.  
  51.   SQLDBLibraryLoader1.ConnectionType:='Firebird';
  52.   SQLDBLibraryLoader1.LibraryName:=FirebirdPath;
  53.   SQLDBLibraryLoader1.Enabled:=True;
  54.  
  55.   IBConnection1.DatabaseName:=DataPath;
  56.   IBConnection1.Connected:=True;
  57.  
  58.  
  59.   SQLTransaction1.DataBase:=IBConnection1;
  60.  
  61.   SQLQuery1.Transaction:=SQLTransaction1;
  62.   SQLQuery1.SQLConnection:=IBConnection1;
  63.   SQLQuery1.SQL.Text:='select RDB$Relation_Name from RDB$RELATIONS where RDB$Relation_Name not like ''%$%''';
  64.   SQLQuery1.Open;
  65.   SQLQuery1.Active:=True;
  66.   DataSource1.DataSet := SQLQuery1;
  67.   DBNavigator1.DataSource := DataSource1;
  68.   DBGrid1.DataSource := DataSource1;
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81. end;
  82.  
  83.  
  84. end.
  85.  
  86.  

I don't know if this database is fully displayed?


Raf20076

  • Full Member
  • ***
  • Posts: 183
    • https://github.com/Raf20076
Re: Firebird embedded error
« Reply #5 on: February 18, 2025, 12:20:27 pm »
OK UPDATE IMPROVED VERSION


Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, DB, IBConnection, SQLDBLib, SQLDB, Forms,
  9.   Controls, Graphics, Dialogs, DBCtrls, DBGrids, StdCtrls;
  10.  
  11. type
  12.  
  13.   { TForm1 }
  14.  
  15.   TForm1 = class(TForm)
  16.     DataSource1: TDataSource;
  17.     DBGrid1: TDBGrid;
  18.     DBNavigator1: TDBNavigator;
  19.     IBConnection1: TIBConnection;
  20.     Label1: TLabel;
  21.     SQLDBLibraryLoader1: TSQLDBLibraryLoader;
  22.     SQLQuery1: TSQLQuery;
  23.     SQLTransaction1: TSQLTransaction;
  24.     procedure FormCreate(Sender: TObject);
  25.  
  26.   private
  27.  
  28.   public
  29.  
  30.   end;
  31.  
  32. var
  33.   Form1: TForm1;
  34.  
  35. implementation
  36.  
  37. {$R *.lfm}
  38.  
  39. { TForm1 }
  40.  
  41. procedure TForm1.FormCreate(Sender: TObject);
  42.  var
  43.   DataPath:AnsiString;
  44.   FirebirdPath: AnsiString;
  45. begin
  46.  
  47.  
  48.   DataPath := ExtractFilePath(Application.ExeName) + 'data\employee.fdb'; // database
  49.   FirebirdPath := ExtractFilePath(Application.ExeName) + 'firebird\fbclient.dll'; // firebird dll's
  50.  
  51.   SQLDBLibraryLoader1.ConnectionType:='Firebird';
  52.   SQLDBLibraryLoader1.LibraryName:=FirebirdPath;
  53.   SQLDBLibraryLoader1.Enabled:=True;
  54.  
  55.   IBConnection1.DatabaseName:=DataPath;
  56.   IBConnection1.Connected:=True;
  57.  
  58.  
  59.   SQLTransaction1.DataBase:=IBConnection1;
  60.  
  61.   SQLQuery1.Transaction:=SQLTransaction1;
  62.   SQLQuery1.SQLConnection:=IBConnection1;
  63.   SQLQuery1.SQL.Text:='select * from CUSTOMER'; //show only customers from database
  64.   //Show all from database
  65.   //SQLQuery1.SQL.Text:='select RDB$Relation_Name from RDB$RELATIONS where RDB$Relation_Name not like ''%$%''';
  66.   SQLQuery1.Open;
  67.   SQLQuery1.Active:=True;
  68.   DataSource1.DataSet := SQLQuery1;
  69.   DBNavigator1.DataSource := DataSource1;
  70.   DBGrid1.DataSource := DataSource1;
  71.  
  72.  
  73. end;
  74.  
  75.  
  76. end.
  77.  
  78.  

 

TinyPortal © 2005-2018