Subject IBO Tutorials
Author paul.linehan@datalex.ie
Hi all,


I'm finally getting to grips with programming against InterBase
in preparation for a College (night course) project next
year - I want to do something with InterBase.


However, I run the first tutorial (creating a db called
tutorial.gdb) on the Windows box I'm programming on.

If I connect to the db, the programme sees that it's not
there and creates it. So then I twiddle between the disconnect
and connect buttons and it obviously sees that now it is
there so it doesn't try and do anything else. Fine.

Here's the catch...

I modify the code slightly (see below) to put a Linux server
that I have running Interbase into action. Make the first call
to create and everything goes fine (db is created and
populated with data). Then I disconnect and try to reconnect
and it gives me the error

raised exception class EIB_ISCError with message ISC
Error code:335544721

ISC Error Message

Unable to complete network request to host "Linux"
Failed to locate host machine
Failed to locate host machine
The specified name was not found in the hosts file or Domain Name
Services
Process stopped....blahdiblah...


Now, why is it doing this? It knows my server is "mel" which
*_is_* in the hosts file - how does it create the db in the
first place?


I would be grateful if somebody could explain what I am
doing wrong.


Code included below. I put "Paul" where I changed code.


Paul...


Replace the FormCreate proc with this.

-------------------
procedure TfrmTutorial1.FormCreate(Sender: TObject);
begin
FDBPath := 'mel:/opt/interbase/examples/' + 'TUTORIAL.GDB'; // Paul
scrMain.SQL.Insert(0, 'CREATE DATABASE ' + '''' + FDBPath + '''');
scrMain.SQL.Insert(1, 'USER ' + '''' + 'SYSDBA' + '''');
scrMain.SQL.Insert(2, 'PASSWORD ' + '''' + 'masterkey' + ''''
+ ';');
FOriginalCaption := Caption;
UpdateFormCaption;
ShowHint := True;
with pagMain do ActivePage := FindNextPage(nil, True, True);
InitializeConnection; // Defines the Connection settings.
InitializeTransaction; // Defines the Transaction's behaviour.
InitializeConnectionBar; // Defines the behaviour of the
ConnectionBar.
end;
--------------------

and the initialise to this


--------------------

procedure TfrmTutorial1.InitializeConnection;
begin
{ IBO speaks to Interbase Server via a TIB_Connection component.
The IB_Database component is just a TIB_Connection but with a
whole lot of
extra features ( like a built in transaction component ) that
together act
more like the VCL TDatabase. For the best results, it is advised
to use
a TIB_Connection though, as it gives you much more control,
functionality
and power. }
with cnMain do begin

{ Let's make sure that we are not still connected from design-
time! }
Connected := False;

{ Since we're going to set *all* the properties in code, even the
login parameters, then we do not want IBO to ask for login
info. }
LoginPrompt := False;

{ The login information has to be set via the
IB_Connection.Params }
with Params do begin
Values['USER NAME'] := 'SYSDBA'; // Remember to set this
appropriately!
Values['PASSWORD'] := 'masterkey'; // Remember to set this
appropriately!
end; { with }
{ Set the name of the Server wher you are accessing Interbase
Server from.
If IBServer is on the local machine, then leave this blank. If,
for
example, IBServer is on a WindowsNT machine
called 'MAIN_SERVER', then
set this property to 'MAIN_SERVER'. }
Server := 'mel:'; // Paul.
{ Set the Path and Name of the Database that you want to use.
This is the
actual *fully-qualified* path and filename on the machine where
the
database is sitting; UNC names, share names, etc are not valid.
[ Note this is an Interbase restriction, not a 'feature' of
IB_Objects. ]
For example, if the server is 'MAIN_SERVER', and your DataBase
is
'MyDatabase.gdb' then:
The following type of path is *NOT* valid: (e.g.)
'\\MAIN_SERVER\DATA\MyDatabase.GDB'.
However, the following type of path *IS* valid: (e.g.)
'D:\Data\Databases\Apps\MyDatabase.GDB'. }
Path := FDBPath;

{ Set the Network Protocol that you are accessing the Interbase
Server by.
Generally speaking, if the Interbase Server is running locally
( i.e. on
the same machine as this tutorial ) then the Protocol is
cpLocal.
If the Interbase Server is on another machine on a
Windows95/WindowsNT
network then you are most likely using cpNETBEUI or cpTCP_IP.
cpNovell refers to the IPX/SPX protocol, *usually* only found
on a Novell
Netware network.
Make sure you Include the file IB_Session when you reference
the protocol
directly like this in code. }

Protocol := cpTCP_IP // Paul
// Protocol := cpLocal; // both on local and TCP_IP causes
problems
end; { with }
end;