Subject | Re: [IBO] CreateDatabase() causing AV |
---|---|
Author | Helen Borrie |
Post date | 2006-01-29T22:52:59Z |
At 07:41 AM 30/01/2006, you wrote:
quoted string is appearing somewhere in the application as a Delphi
string, it is wrong. To be parsed correctly, it would require escape
quotes on the literal apostrophes, viz:
SomeDelphiString := ''CREATE DATABASE ''E:\ibotest\testi1.fdb'' USER
''sahokas'' PASSWORD
''salasana'' PAGE_SIZE = 1024'
In case you are reading this in a proportional font, those are not
double quotes, but "doubled" single quotes.
and set it up to point to your ib_connection (selection
IB_Connection1 as the IB_Connection property). Then set the
DefaultTransaction property of your connection to be this
transaction. And, since you are assigning your ib_connection
properties via code, take explicit control of starting the
transaction. You won't have to commit it - the server will do that
because of the ExecuteImmediate call.
Also don't allow IBO to set the page size (1024 is too small for
modern editions of Firebird/IB, Jason needs to fix up this default or
remove it!)
So try this revised code:
with IB_Connection1 do begin
if DefaultTransaction.TransactionIsActive then
DefaultTransaction.Rollback;
Username:='sahokas';
Password:='salasana';
Protocol:=cpLocal;
PageSize := 4096; // or 8192
SQLDialect := 3;
DatabaseName:='E:\ibotest\testi1.fdb'; // make sure it doesn't exist
DefaultTransaction.StartTransaction;
CreateDatabase;
end;
Also, you don't mention whether you are running a Classic or
Superserver. If it is a Classic server, then cpLocal is not
supported. For a local connection to a Classic server you must use
cpTCP_IP as your protocol and provide 'localhost' or '127.0.0.1' as
the Server property.
Helen
>Greetings,Where are you reading this string?
>
>This is my first post here, and I'm still rather new to IBO/FB.
>
>I am trying to create a database from my program, using
>IB_Connection.CreateDatabase() but it keeps failing due to access violation.
>
>I am using D2006Pro and IBO 4.6A beta (which Jason sent me to test IBO
>in D2006, and I have no other version of IBO available since I have not
>yet received response to trustware application).
>
>What I am exactly doing is:
>
>- I have a project with 1 form, which contains 1 button and 1
>TIB_Connection component
>
>- I have the following code on button's OnClick
>
>with IB_Connection1 do begin
> Username:='sahokas';
> Password:='salasana';
> Protocol:=cpLocal;
> DatabaseName:='E:\ibotest\testi1.fdb';
> CreateDatabase;
>end;
>
>When execution gets to call to CreateDatabase(), I am getting AV:
>
>"Access Violation at address 0000... Read of address 0000...."
>
>Exact point where it happens is in IB_Session.pas at the following call:
> errcode := isc_dsql_execute_immediate( @Status,
> @dbHandle,
> @trHandle,
> null_terminated,
> PChar(CreateString),
> SQLDialect,
> nil );
>
>At that point CreateString is as follows:
>'CREATE DATABASE 'E:\ibotest\testi1.fdb' USER 'sahokas' PASSWORD
>'salasana' PAGE_SIZE = 1024'
>The exactly same string (without ' in the beginning and end of course)The "string" that works is a valid SQL statement. If the above
quoted string is appearing somewhere in the application as a Delphi
string, it is wrong. To be parsed correctly, it would require escape
quotes on the literal apostrophes, viz:
SomeDelphiString := ''CREATE DATABASE ''E:\ibotest\testi1.fdb'' USER
''sahokas'' PASSWORD
''salasana'' PAGE_SIZE = 1024'
In case you are reading this in a proportional font, those are not
double quotes, but "doubled" single quotes.
>works fine when used from from commandline windows ISQL. ISQL and myThe first thing I would try is drop a TIB_Transaction onto the form
>program are running from the same directory so version of the DLL and
>everything else should be the same.
>
>I have tried setting more properties in IB_Connection (charset,
>forcedwrites, loginprompt, pagesize, etc) and tried connecting to remote
>server as well. I'm using the latest 1.5.3 release and I have tried with
>both fbembedd.dll and fbclient.dll, renamed to gds32.dll etc. Result is
>always the same. Connecting to a database made with other application
>works fine using IB_Connection.Connect().
>
>Any input or pointer where to look would be much appreciated, running
>out of ideas here.
and set it up to point to your ib_connection (selection
IB_Connection1 as the IB_Connection property). Then set the
DefaultTransaction property of your connection to be this
transaction. And, since you are assigning your ib_connection
properties via code, take explicit control of starting the
transaction. You won't have to commit it - the server will do that
because of the ExecuteImmediate call.
Also don't allow IBO to set the page size (1024 is too small for
modern editions of Firebird/IB, Jason needs to fix up this default or
remove it!)
So try this revised code:
with IB_Connection1 do begin
if DefaultTransaction.TransactionIsActive then
DefaultTransaction.Rollback;
Username:='sahokas';
Password:='salasana';
Protocol:=cpLocal;
PageSize := 4096; // or 8192
SQLDialect := 3;
DatabaseName:='E:\ibotest\testi1.fdb'; // make sure it doesn't exist
DefaultTransaction.StartTransaction;
CreateDatabase;
end;
Also, you don't mention whether you are running a Classic or
Superserver. If it is a Classic server, then cpLocal is not
supported. For a local connection to a Classic server you must use
cpTCP_IP as your protocol and provide 'localhost' or '127.0.0.1' as
the Server property.
Helen