Jump to content
tobenschain

FireDAC open error

Recommended Posts

I do not understand why I am getting 

 

[FireDAC][Stan][Def]-254. Definition [C:\Prog2\employee.fdb] is not found in [C:\WINDOWS\FDConnectionDefs.ini]

 

This is C:\WINDOWS\FDConnectionDefs.ini

 

[EMPLOYEE]
DriverID=FB
Protocol=TCPIP
Database=C:\Prog2\employee.fdb
User_Name=sysdba
Password=masterkey
CharacterSet=
ExtendedMetadata=True

 

I am using XE7. This is my code

 

  var  out_Table: TFDTable; out_Connection: TFDConnection;
 
begin
  out_Table := TFDTable.Create(Application);

  with out_Table, FieldDefs do begin
    Clear;
    Add('key',ftString, 51);
    Add('data',ftString, 32{000});
    Add('control',ftString, 32{000});
    TableName := out_Table.Name;
    Convert := TConvert.Create(Application);

    Connection := Convert.FDConnection1;
    Active := true;
    end;
 

Share this post


Link to post

The file has a definition of EMPLOYEE not C:\Prog2\employee.fdb.

 

What is the definition/settings for Convert.FDConnection1?

Share this post


Link to post

In this code snippet you don't have how you set up the connection and that's the error you got.

 

My guess is that in your code somewhere the connection's ConnectionDefName property is set to C:\Prog2\employee.fdb instead of EMPLOYEE.

 

 

Share this post


Link to post

Now I get

 

'[FireDAC][Phys][FB]I/O error during 
"CreateFile (open)" operation for file ":C:\Prog2\employee.fdb"
Error while trying to open file
The filename, directory name, or volume label syntax is incorrect. 

 

I set ConnectionDefName. I posted the wrong .pas code. It is now

 

type
  TForm2 = class(TForm)
    DBNavigator1: TDBNavigator;
    DataSource1: TDataSource;
    Cprog2employeefdbConnection: TFDConnection;
    FDTable1: TFDTable;
    procedure FormCreate(Sender: TObject);
  end;

 

procedure TForm2.FormCreate(Sender: TObject);
begin  with FDTable1, FieldDefs do begin
    Clear;
    Add('key',ftString, 10);
    Add('data',ftString, 32{000});
    Add('control',ftString, 32{000}); end;
  Cprog2employeefdbConnection.Connected := true;
end;

image.thumb.png.5ad9fbdf89f36bbf521b3b9b8f761459.png

image.thumb.png.a3f14c0151d0be07da5f476816272328.png

image.thumb.png.63607cc9deee70e515f36684c4be4ec3.png
image.thumb.png.e804f5f6e64ce5ecd84162e38f26f1b8.png

image.thumb.png.0957b384830bc8d3588d28433a6c8a7c.png

Share this post


Link to post

unit2.dfm:

 

object Form2: TForm2
  Left = 0
  Top = 0
  Caption = 'Form2'
  ClientHeight = 411
  ClientWidth = 710
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  OnCreate = FormCreate
  PixelsPerInch = 96
  TextHeight = 13
  object DBNavigator1: TDBNavigator
    Left = 68
    Top = 39
    Width = 240
    Height = 25
    TabOrder = 0
  end
  object DBGrid1: TDBGrid
    Left = 18
    Top = 83
    Width = 675
    Height = 311
    DataSource = DataSource1
    TabOrder = 1
    TitleFont.Charset = DEFAULT_CHARSET
    TitleFont.Color = clWindowText
    TitleFont.Height = -11
    TitleFont.Name = 'Tahoma'
    TitleFont.Style = []
  end
  object DataSource1: TDataSource
    DataSet = FDTable1
    Left = 345
    Top = 36
  end
  object Cprog2employeefdbConnection: TFDConnection
    Params.Strings = (
      'ConnectionDef=EMPLOYEE')
    LoginPrompt = False
    Left = 103
    Top = 159
  end
  object FDTable1: TFDTable
    Connection = Cprog2employeefdbConnection
    Left = 244
    Top = 163
  end
end

Share this post


Link to post

The error message shows a colon at the start of the path\file. 

 

":C:\Prog2\employee.fdb"

 

Your code shows signs of leftovers from trying different things. Make a NEW project and get a connection working with as little as possible. Once done clean up the old code to match. 

 

Share this post


Link to post

When you use the tcp/ip connection, you must define the server. If you are running you DB on same computer as program, you can use the 127.0.0.1 ip address.

Share this post


Link to post
On 7/6/2022 at 11:53 AM, tobenschain said:

I need to somehow reinstall the FireBird Data Explorer 

Why are you using Firebird?

Share this post


Link to post
40 minutes ago, weirdo12 said:

Why are you using Firebird?

I see this is an old question 😉 Anyway, I should have asked: Is there a particular reason you are using Firebird?

Share this post


Link to post
On 7/20/2022 at 10:13 PM, tobenschain said:

i got it to work and it's free

Did you consider just using SQLite?

Share this post


Link to post

in fact, you can do the "backup" as any other file-DB!

type
  TForm1 = class(TForm)
    FDConnection1: TFDConnection;
    FDPhysSQLiteDriverLink1: TFDPhysSQLiteDriverLink;
    FDGUIxWaitCursor1: TFDGUIxWaitCursor;
    Button1: TButton;
    DBGrid1: TDBGrid;
    DataSource1: TDataSource;
    FDQuery1: TFDQuery;
    Button2: TButton;
    FDSQLiteBackup1: TFDSQLiteBackup;
    DBGrid2: TDBGrid;
    FDConnection2: TFDConnection;
    FDQuery2: TFDQuery;
    DataSource2: TDataSource;
    Button3: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  FDConnection1.Params.Database := ':memory:';
  FDConnection1.ExecSQL('create table mytable(id integer, names varchar(20));');
  FDConnection1.ExecSQL('insert into mytable values(1, ''john'');');
  FDConnection1.ExecSQL('insert into mytable values(2, ''mary'');');
  FDConnection1.ExecSQL('insert into mytable values(3, ''peter'');');
  FDQuery1.Open('select * from mytable');

end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  FDSQLiteBackup1.DriverLink   := FDPhysSQLiteDriverLink1;
  FDSQLiteBackup1.DatabaseObj  := FDConnection1.CliObj;  // <-- your DB opened on FDConnnect1 -> :memory: in case!
  FDSQLiteBackup1.DestDatabase := 'mySQLiteTarget.db';  // <-- file to save on disk or you can target to another ":memory:"
  FDSQLiteBackup1.Backup;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  FDConnection2.Close;
  FDConnection2.Params.Database := 'mySQLiteTarget.db';
  FDConnection2.DriverName      := 'SQLite';
  FDQuery2.Open('select * from mytable');
end;

end.
...
  object FDConnection1: TFDConnection
    Params.Strings = (
      'DriverID=SQLite')
  end
  object FDPhysSQLiteDriverLink1: TFDPhysSQLiteDriverLink
  end
  object FDGUIxWaitCursor1: TFDGUIxWaitCursor
    Provider = 'Forms'
  end
  object DataSource1: TDataSource
    DataSet = FDQuery1
  end
  object FDQuery1: TFDQuery
    Connection = FDConnection1
  end
  object FDSQLiteBackup1: TFDSQLiteBackup
    Catalog = 'MAIN'
    DestCatalog = 'MAIN'
  end
  object FDConnection2: TFDConnection
  end
  object FDQuery2: TFDQuery
    Connection = FDConnection2
  end
  object DataSource2: TDataSource
    DataSet = FDQuery2
  end
end

image.thumb.png.54bae17089dd58303bc67652221d15fa.png

Edited by programmerdelphi2k

Share this post


Link to post

about Firebird usage, not problem at all! 

you can choice between 3 connnection type: this is not about database usage, just "about the connection type used by FireDAC"

just inform the right params to find the "FDB" file, as well as the library (FBClient.DLL) path! Else, the FireDAC will try find in default system folders

  • you can have a "FDConnectionsDef.ini" in your exe folder! not needs use the Embarcadero default!
Edited by programmerdelphi2k

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×