Subject How to bring DB online with Firebird API - 'Unrecognized service parameter bloc'
Author vincent_kwinsey
Hi,

I need to bring DB online using FB API, because I am not allowed to
use IBC Admin components. So - there are 4 FB service API, and I
worte the following code:

[CODE]
procedure TMainForm.Button1Click(Sender: TObject);
var stat: isc_status;
sv: status_vector;
service_name: String;
spb: String;
username, password, dbname: String;
begin
//MMX
@IscServiceAttach := GetProcAddress
(LibHandle, 'isc_service_attach');
if @IscServiceAttach = nil then
raise Exception.Create('Failed to lookup isc_service_attach');

@IscServiceStart := GetProcAddress(LibHandle, 'isc_service_start');
if @IscServiceStart = nil then
raise Exception.Create('Failed to lookup isc_service_start');

username:='SYSDBA';
password:='masterkey';
service_name:=editServiceName.Text;
serviceHandle:=0;
spb:=char(isc_spb_version)+char(isc_spb_current_version);
spb:=spb+char(isc_dpb_user_name)+char(Length(username))+username;
spb:=spb+char(isc_dpb_password)+char(Length(password))+password;
stat:=ISCServiceAttach(@sv,Length(service_name), pchar
(service_name), @serviceHandle,
Length(spb),pchar(spb));
lblStatusCode.Caption:=IntToStr(stat);


dbname:=editDBName.Text;
spb:='';
spb:=char(isc_action_svc_properties);
spb:=spb+char(isc_spb_dbname)+char(Length(dbname))+dbname;
spb:=spb+char(isc_spb_prp_db_online);
stat:=ISCServiceStart(@sv,@serviceHandle,nil,Length(spb),pchar
(spb));
lblStartStatusCode.Caption:=IntToStr(stat);

end;
[/CODE]

There are several defintions in other files, but the idea should be
clear. The proble is with the last block of code - where I am
popoulating spb for use in in ISCServiceStart. I provide database
name in dbname and isc_spb_prp_db_online is constant as defined after
information from: http://www.freepascal.org/docs-
html/packages/ibase60/isc_spb_dbname.html and so on (I am not using
ibase.h, because my code is in pascal). So - after execution in
ISCService I am getting 'Unrecognized service parameter block
335544562', so - I guess that I should the the error in the content
of spb. The content os spb is descriped in the old Interbase API
guide and I guess that my approach is correct. Well - there is mistiq
saying that length for dbname should be increased by 2 and the length
of isc_spb_prp_db_online is just bit - but can my present code be
really solved by observing this?

So - can anyone provide me some guidance how to proceed with removing
this error? I tried to see the gfix code (I guess, it should use
API), but I could not any normal use (except definition) of
isc_spb_prp_db_online and isc_action_svc_properties not in FB 1.5.5
code nor in FB API samples which comes with FB installation as well.
Actually - there is only one event monitor example for use of FB
service API in the part of thewhole web available to me, so - this is
rare issue...

Thanks in advance, if someone can provide me some suggestion!!