Subject Create database from Delphi application
Author Christian Kaufmann
Hi,

I try to write a small function to create a database. This works fine
so far, but I get an exception either on the detach command or later
when I free the library.

Can somebody give me a hint, what may go wrong?

I'm aware, that currently all error handling is missing.

cu Christian


uses
IBHeader, IBExternals;


procedure TestCreateDB;
var
fbDLL : THandle;
isc_dsql_execute_immediate : Tisc_dsql_execute_immediate;
isc_detach_database : Tisc_detach_database;
db_handle : TISC_DB_HANDLE;
tr_handle : TISC_TR_HANDLE;
statusVector : ISC_STATUS;
dbCreateSql : String;
begin
dbCreateSql :=
'create database ''d:\tests\testDB.fdb'' user ''sysdba''
password ''masterkey'' '
+ 'page_size 4096 default character set ISO8859_1';
fbDLL := LoadLibrary('fbembed.dll');
try
isc_detach_database := GetProcAddress(fbDLL, 'isc_detach_database');
isc_dsql_execute_immediate := GetProcAddress(fbDLL,
'isc_dsql_execute_immediate');

tr_handle := nil;
db_handle := nil;

isc_dsql_execute_immediate(@statusVector, @db_handle, @tr_handle,
0, PChar(dbCreateSql), 3, nil);
isc_detach_database(@statusVector, @db_handle);
finally
FreeLibrary(fbDLL);
end;
end;