Subject Re: [firebird-support] Simple isc_attach_database Question
Author Helen Borrie
At 11:37 AM 1/05/2007, you wrote:
>Hi.
>
>I need to attach to a DB across a LAN, but all of the examples show
>attachments similar to:
>
>isc_attach_database(
>status_vector,
>0,
>"employee.db",
>&handle,
>dpb_length,
>dpb_buffer);
>
>
>Can someone post a couple examples of using the API to connect across
>the LAN??

Those examples are horrible. The member that the example shows as
"employee.db" needs to be a valid connection specification,
consisting of two elements in the correct format for the server, viz.

Element 1. hostname. This is mandatory except in two *specific*
client/server conditions, each of which is specific to the OS and the
application architecture. On Windows, it is the IPServer "local"
connection via Superserver or the embedded server; on POSIX
platforms it is the Classic server when using the libfbembed.so client.

Otherwise, the hostname must be either the LAN-recognised hostname of
the server. If the connection protocol is TCP/IP, it can be the IP
address instead, as long as the IP address of the host is statically
defined and reserved. It cannot be a virtual server

Element 2. file path. This is the filesystem path to the database
file, as seen by the server. It cannot be a relative path and it
cannot point to a mapped drive or anything else except the *physical*
location of the file on a hard drive that is controlled directly by
the host server. For a Windows server it has to include the drive
designator of the drive or partition followed by a "/". For POSIX, a
fully qualified path (from root down). You can find examples in the
Quick Start Guide.

On Firebird 1.5 and higher, Element 2 can be a database alias. If
you don't know about database aliases, READ THE V.1.5 RELEASE
NOTES. There is also an example in the alias config file
aliases.conf in the firebird root directory.

Here's one example for the employee database in a standard Firebird
2.0.x installation on Windows, assuming your server's hostname is
"someserver" and the connection protocol is TCP/IP (recommended!):

someserver:c:\Progr~01\Firebird\Firebird_2_0\examples\empbuild\employee.fdb

If you have the file location aliased, e.g.

empdb = c:\Program Files\Firebird\Firebird_2_0\examples\empbuild\employee.fdb
then your connect string can be:
someserver:empdb

Similar if your server is the standard Linux installation:

someserver:/opt/firebird/examples/empbuild/employee.fdb

Or aliased as
empdb = /opt/firebird/examples/empbuild/employee.fdb

Connection string
someserver:empdb

HTH

./heLen