Board index » delphi » Valid databasename vs. valid filename problem

Valid databasename vs. valid filename problem

I have just encountered a problem when connecting to a server, as
opposed to using local IB.

If I set the IBDatabase.Databasename to a valid NetBEUI string
(eg '\\MYSERVER\F:\MYDIR\MYDB.GDB') or TCP/IP string
(eg 'MYSERVER:F:\MYDIR\MYDB.GDB'), then I cannot pass the same
string to FileExists to check before attempting to connect.

When I used the OpenFile dialog to check, the string returned
was 'MYSERVER\F\MYDIR\MYDB.GDB', but as the app may be installed
with either local or client IB, I can't just remove the colons
when using FileExists.

Currently this string is set in an INI file as a single string.

Does anyone have a simple workaround?
(Not an IBX problem, I know, but...)

---
Sarah
[not a 'SQL smartie' yet!]

 

Re:Valid databasename vs. valid filename problem


You can't assume that the drive on the server where Interbase is installed
will be accessible from the client (it almost always should not be shared
since Interbase doesn't need it to be).

A better approach would be to catch the exception that Interbase throws when
trying to open the database if the file doesn't exit.

Dan

Quote
"Sarah Mould" <nos...@adp-es.nospam.uk> wrote in message

news:3d0f4fd6.3868289@newsgroups.borland.com...
Quote
> I have just encountered a problem when connecting to a server, as
> opposed to using local IB.

> If I set the IBDatabase.Databasename to a valid NetBEUI string
> (eg '\\MYSERVER\F:\MYDIR\MYDB.GDB') or TCP/IP string
> (eg 'MYSERVER:F:\MYDIR\MYDB.GDB'), then I cannot pass the same
> string to FileExists to check before attempting to connect.

> When I used the OpenFile dialog to check, the string returned
> was 'MYSERVER\F\MYDIR\MYDB.GDB', but as the app may be installed
> with either local or client IB, I can't just remove the colons
> when using FileExists.

> Currently this string is set in an INI file as a single string.

> Does anyone have a simple workaround?
> (Not an IBX problem, I know, but...)

> ---
> Sarah
> [not a 'SQL smartie' yet!]

Re:Valid databasename vs. valid filename problem


On Tue, 18 Jun 2002 08:38:38 -0700, "Dan Palley" <d...@trams.com>
wrote:

Quote
>You can't assume that the drive on the server where Interbase is installed
>will be accessible from the client (it almost always should not be shared
>since Interbase doesn't need it to be).

>A better approach would be to catch the exception that Interbase throws when
>trying to open the database if the file doesn't exit.

Wow! quick response!

That is what I had originally coded, but I am parsing the INI file and
doing various other jobs before opening the db, so I wanted a 'quick
check' that the INI entry is valid. Would you suggest I change this to
attempt to connect to the db before doing any other setup stuff? Seems
to me that may become a problem with usernames/passwords/roles, though
perhaps I could just connect as SYSDBA and then immediately
disconnect.

---
Sarah
[not a 'SQL smartie' yet!]

Re:Valid databasename vs. valid filename problem


Quote
"Sarah Mould" <nos...@adp-es.nospam.uk> wrote in message

news:3d0f54d5.5147569@newsgroups.borland.com...

Quote
> Wow! quick response!

> That is what I had originally coded, but I am parsing the INI
file and
> doing various other jobs before opening the db, so I wanted a
'quick
> check' that the INI entry is valid. Would you suggest I change
this to
> attempt to connect to the db before doing any other setup stuff?
Seems
> to me that may become a problem with usernames/passwords/roles,
though
> perhaps I could just connect as SYSDBA and then immediately
> disconnect.

That's what I do in my programs. Initially, the setup routine is
run to read the information in certain tables. I connect as SYSDBA
to do this, then I close the connection and connect as the user.
If the first connection fails, then I set a flag and no operations
can take place that use the database. The user is then free to run
the setup form in the program and change the server and
path\database name from the INI file to what it should be. If the
database is just down or missing (??), then they have to wait
until it's resolved.

HTH
Woody (TMW)

Re:Valid databasename vs. valid filename problem


Thanks Woody, and thanks Dan - I'll go with this.

---
Sarah
[not a 'SQL smartie' yet!]

Other Threads