Subject | Re: [IBO] CreateDatabase() causing AV |
---|---|
Author | Helen Borrie |
Post date | 2006-01-30T11:08:10Z |
At 09:29 PM 30/01/2006, you wrote:
everything in the DFM so you can see what I did:
object Form1: TForm1
Left = 192
Top = 107
Width = 408
Height = 170
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Button1: TButton
Left = 24
Top = 24
Width = 169
Height = 25
Caption = 'Create Database'
TabOrder = 0
OnClick = Button1Click
end
object cn: TIB_Connection
DefaultTransaction = tr1
SQLDialect = 3
Params.Strings = (
'PATH=l:\data\test\createdatabase.fdb'
'PAGE SIZE=4096'
'SQL DIALECT=3'
'USER NAME=sysdba')
Left = 32
Top = 40
end
object tr1: TIB_Transaction
IB_Connection = cn
Isolation = tiCommitted
Left = 88
Top = 40
end
end
Here's the code from the unit:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IB_Components;
type
TForm1 = class(TForm)
cn: TIB_Connection;
tr1: TIB_Transaction;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
with cn do
begin
if DefaultTransaction.TransactionIsActive then
DefaultTransaction.Rollback;
DefaultTransaction.StartTransaction;
CreateDatabase;
if DefaultTransaction.InTransaction then
DefaultTransaction.Commit;
if not Connected then Connect;
Button1.Enabled := not Connected;
end;
end;
end.
No AVs, everything works as expected.
So, let's try to find out what was wrong in your setup.
e.g. if you were trying to access a server on Linux, does the
firebird user (or group) have the needed permissions to create a file?
Does IBO know where to find your client? Or, to put it another way,
is there a correctly-named client in a place where IBO can find it...
1) Client to a full server: fbclient.dll resident in the system
directory (unless you intervene at source code level and tell it otherwise)
or
2) If Embedded is all you have available, you won't be able to
access a DB anywhere except locally, using cpLocal for protocol, and
fbEmbed.dll has to be renamed to fbclient.dll and located in the same
directory as your exe.
Avoid the DatabaseName property: using the Path and (if applicable)
the Server properties is much more robust.
Helen
>However, the actual problem still remains the same: IBO does not seemI just threw together a little test app similar to yours, but I put
>to load any client dll, should it be fbembed.dll renamed to
>gds32.dll/fbclient.all or the "real" fbclient.dll, when calling
>CreateDatabase(). Once dll is loaded, for example after a connection
>attempt, CreateDatabase() works just fine. What I am wondering is if
>this is intentional (ie. I should do some kind of initialization before
>calling it) or if it is a bug.
everything in the DFM so you can see what I did:
object Form1: TForm1
Left = 192
Top = 107
Width = 408
Height = 170
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Button1: TButton
Left = 24
Top = 24
Width = 169
Height = 25
Caption = 'Create Database'
TabOrder = 0
OnClick = Button1Click
end
object cn: TIB_Connection
DefaultTransaction = tr1
SQLDialect = 3
Params.Strings = (
'PATH=l:\data\test\createdatabase.fdb'
'PAGE SIZE=4096'
'SQL DIALECT=3'
'USER NAME=sysdba')
Left = 32
Top = 40
end
object tr1: TIB_Transaction
IB_Connection = cn
Isolation = tiCommitted
Left = 88
Top = 40
end
end
Here's the code from the unit:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IB_Components;
type
TForm1 = class(TForm)
cn: TIB_Connection;
tr1: TIB_Transaction;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
with cn do
begin
if DefaultTransaction.TransactionIsActive then
DefaultTransaction.Rollback;
DefaultTransaction.StartTransaction;
CreateDatabase;
if DefaultTransaction.InTransaction then
DefaultTransaction.Commit;
if not Connected then Connect;
Button1.Enabled := not Connected;
end;
end;
end.
No AVs, everything works as expected.
So, let's try to find out what was wrong in your setup.
e.g. if you were trying to access a server on Linux, does the
firebird user (or group) have the needed permissions to create a file?
Does IBO know where to find your client? Or, to put it another way,
is there a correctly-named client in a place where IBO can find it...
1) Client to a full server: fbclient.dll resident in the system
directory (unless you intervene at source code level and tell it otherwise)
or
2) If Embedded is all you have available, you won't be able to
access a DB anywhere except locally, using cpLocal for protocol, and
fbEmbed.dll has to be renamed to fbclient.dll and located in the same
directory as your exe.
Avoid the DatabaseName property: using the Path and (if applicable)
the Server properties is much more robust.
Helen