How to format the db_name parameter in the isc_attach_database() API call.

By: Borland Staff

Abstract: There are some formatting issues with the db_name parameter

Problem:
In using the isc_attach_database() API function there are some formatting issues with the db_name
parameter that are not obvious and may delay employing this function in an embedded C/C++ 
application.  This document addresses these formatting issues.

Solution:
In passing in parameters to the isc_attach_database() function, it is important to note how the
function is defined in the C/C++ host language.  For the C/C++ languages,  the 
isc_attach_database() API call is defined as follows in the API Guide:

  ISC_STATUS isc_attach_database(ISC_STATUS* status_vector,
                                 short db_name_length,
                                 char *db_name,
                                 isc_db_handle *db_handle,
                                 short perm_buffer_length,
                                 char *parm_buffer);                                
  
The db_name parameter is used to pass in the location of the .gdb file to open.  Whether db_name
is a pointer to a null-terminated string (e.g. db_name, where db_name is defined as
"char  *db_name") or a reference to an array of type char (e.g. &db_name, where db_name is defined
as "char  db_name[]") does not make a difference.  To attach to a database using a local 
connection, a TCP/IP connection or a NetBEUI connection it would seem obvious, for example 
assuming that the name of the server where the .gdb file(s) reside is named Tempest, to use the 
following strings in db_name:

  Local:   c:Program FilesIntrbaseExamplesEmployee.gdb
  TCP/IP:  Tempest:c:Program FilesIntrbaseExamplesEmployee.gdb
  NetBEUI: //Tempest/c:Program FilesIntrbaseExamplesEmployee.gdb

If the format of these strings is used the connection will fail because of how the db_name string is 
parsed.  The '' character indicates a special (untype-able) character is immediately following the
 '' character. To allow normal parsing of the string change the formatting to one of the following styles 
of formatting:

  Local:   c:Program FilesIntrbaseExamplesEmployee.gdb
  TCP/IP:  Tempest:c:Program FilesIntrbaseExamplesEmployee.gdb
  NetBEUI: //Tempest/c:Program FilesIntrbaseExamplesEmployee.gdb

or

  Local:   c:/Program Files/Intrbase/Examples/Employee.gdb
  TCP/IP:  Tempest:c:/Program Files/Intrbase/Examples/Employee.gdb
  NetBEUI: //Tempest/c:/Program Files/Intrbase/Examples/Employee.gdb

In other words, change the '' character to either '' or '/'.

Server Response from: ETNASC03