Subject Re: [IBO] Server Connection .v. Local Connection
Author Helen Borrie
At 12:55 PM 6/11/2003 +0000, you wrote:
>Hi all..
>
>I am currently trying to connect to a server based database.
>
>The database I wish to connect to is defined in a security db on the
>local machine.
>
> >From this db, the name of the "real" database to be used is retrieved
>and then sent to an AttachToDatabase function in my midas server.
>
>Connecting to a local db works, but when I attempt to connect to a
>server based db, delphi first brings up the CPU debugger, and then
>after pressing F9, it seems to connect. (very slowely)
>
>I then as in a C/S environment, hit retrieve to display a list of
>records, which works, and I then double click a record to edit, at
>which stage, I get an error reported in midas.dll.
>
>The following is my connection code snipped somewhat.

I just snipped it to DEATH!!

> Result := 0; // keep this if you need it. :-))

if dbFreight.Connected then
try
dbFreight.Disconnect;
except
<blast the socks off the idjit user>
Exit;
end;
with dbFreight do
try
Database := DBase;
PasswordStorage := psNone;
UserName := UserName; // can you use another variable name?
Password := UserPword;
Connect;
except
<ask user to please plug in network cable>
<and whatever else is necessary>
end;

>Some of this code has legacy stuff in it, which I am unsure yet as to
>keep or delete.

You don't need any of those BDE params!

All of that server path parsing stuff is unnecessary if you already have
the TCP/IP connection string in the DBase variable (and you have, judging
by the parsing). That's more than plenty for IBO to go on: it can work
out the other bits - including protocol - from that. And the slashes for
TCP/IP can be forward or backward, so you don't even need to mudge those.

The same code will work even for local - if there is no MyServer: at the
beginning of the string, IBO knows it's local-connect. (Does Midas even
work with local connect?)

Does one need to mention that tcp/ip local loopback is better for local
connection than using the IPServer local connect?
i.e. localhost:c:\path\to\database rather than just c:\path\to\database
localhost should be defined already in your Hosts file but, if not, you can
put it there:
127.0.0.1 localhost

Helen