I read these files:ZPlainInterbaseDriver.pas,ZPlainFirebird15.pas,
ZPlainloader.pas,and the document Apiguide.pdf
(
http://www.ibphoenix.com/downloads/60ApiGuide.zip),
so I made a test application as following:
unit fbtest;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs,
Buttons, Menus, EditBtn, ComCtrls, DBCtrls, DBGrids, DB, sqldb,
ZDataset, ZConnection, ZSqlProcessor, ZSqlMonitor, ZSequence,
ZPlainFirebird15, ZPlainInterbaseDriver, windows;
type
{ TForm1 }
TForm1 = class(TForm)
...
BtnCreateNewDataBase : TButton;
procedure BtnCreateNewDataBaseClick(Sender: TObject);
...
var
Form1: TForm1;
implementation
...
procedure TForm1.BtnCreateNewDataBaseClick(Sender: TObject);
var
status_vector : PISC_STATUS;
db_handle : TISC_DB_HANDLE;
tran_handle : TISC_TR_HANDLE;
statement : string;
begin
statement := 'CREATE DATABASE ''C:\mydb\test.fdb'' PAGE_SIZE 4096 USER ''SYSDBA'' PASSWORD ''masterkey'';';
isc_dsql_execute_immediate := Tisc_dsql_execute_immediate(GetProcAddress(LoadLibrary('C:\FireBird15\bin\fbclient.dll'),'isc_dsql_execute_immediate'));
db_handle := nil;
tran_handle := nil;
isc_dsql_execute_immediate(status_vector,@db_handle,@tran_handle,0,PChar(statement),3,nil);
end;
The application was compiled and can be run,but when I click on the BtnCreateNewDataBase,
there is a message 'Access violation.Press OK to ignore,press cancel to stop the program'.
(I look at the c:\mydb directory,the new database 'test.fdb' was created and its size is 584kb.)
on page 325 of the document Apiguide.pdf it says:
the 4th parameter of isc_dsql_execute_immediate(Length of the DSQL statement in bytes) should be set to 0 in C programs to
indicate a null-terminated string.
If I change it to Length(statement),the result is the same as above.