Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread Why can't I get GetDatabaseNames() to work?
Thu, Aug 27 2009 12:01 PMPermanent Link

Brent
I'm probably doing something silly here, but I can't figure it out. I want to open an
EDBConfig.EDBCFG and get a list of databases. But it always returns 0 rows. No errors are
reported so it is opening the config file. Here is the code.

       CfgFileName := 'D:\Data\ElevateDb\Tutorial\EDBConfig.EDBCFG';
       with EDBEngine1 do
         begin
           Active     := false;
           ConfigPath := ExtractFilePath(CfgFileName);
           Active     := true;
         end;

       with EDBSession1 do
         begin
           Connected  := false;
           LocalConfigPath := ExtractFilePath(CfgFileName);
           LocalConfigExtension := ExtractFileExt(CfgFileName);
           Connected := true;
           ListBox1.Clear;
           GetDatabaseNames(ListBox1.Items);
           ShowMessage(IntToStr(ListBox1.Items.Count));  //Always 0 rows returned
         end;

So what am I doing wrong. TIA

Brent
Thu, Aug 27 2009 12:22 PMPermanent Link

Uli Becker
Brent,

First of all: if you want to use the LocalConfigPath of the session, be
sure that

TEDBEngine.UseLocalSessionEngineSettings is set to true.

Otherwise the global settings of the engine are use.
Since you set ConfigPath of the engine, it should work anyway.

Are you sure that you already created the databases using CfgFileName?

Uli
Thu, Aug 27 2009 1:20 PMPermanent Link

Brent
<<Uli Becker wrote:

Brent,

First of all: if you want to use the LocalConfigPath of the session, be
sure that

TEDBEngine.UseLocalSessionEngineSettings is set to true.
Otherwise the global settings of the engine are use.
>>


Ok, thanks. I just switched it to True and it didn't make any difference.

<<Since you set ConfigPath of the engine, it should work anyway.
Are you sure that you already created the databases using CfgFileName?>>

Correct. This is the location of the Tutorial database that I created using EDBMgr which
has the Customer table. I can open this database using the EDBMgr and see the Tutorial
database in it and the Customer table. I copied and pasted the text from the Local
Configuration File Folder from the EDBMgr to ConfigPath in my Delphi program to avoid any
typos and added the file extension "EDBConfig.EDBCFG" file name. I can confirm the EDBCFG
file is there. If I change the ConfigPath to something that doesn't exist and run the
program, it reports that it can't find the EDBCFG file. So it is definitely opening the
EDBCFG file because no error is reported with the correct ConfigPath.

I then ran Process Monitor from SysInternals and it confirmed it was opening the
D:\Data\ElevateDb\Tutorial\EDBConfig.EDBCfg file. So I'm at a bit of a loss as to why
GetDatabaseNames() is returning no rows. There is a Tutorial database in there with a
Customer table.

Are there any code examples of this function working? I looked in the help file and manual
and couldn't find any.
TIA

Brent
Thu, Aug 27 2009 1:41 PMPermanent Link

Uli Becker
Brent ,

> Are there any code examples of this function working? I looked in the
help file and manual
> and couldn't find any.

actually you don't need any code to make this work.

> and added the file extension "EDBConfig.EDBCFG" file name

I don't understand what you mean by this. Normally there is no need to
change anything here.

These are the basic steps to setup the database access:

1. Drop a TEDBEngine (MyEngine) component onto your form.
2. Drop a TEDBSession (MySession) component onto your form.
3. Drop a TEDBDatabase (MyDatabase) component onto your form.

Now edit these properties and don't do anything else:

1. MyEngine.ConfigPath := 'D:\Data\ElevateDb\Tutorial';
2. MySession.LoginUser := 'Administrator';
3. MySession.LoginPassword := DefaultPasswordOfEDB;
4. MySession.SessionName := 'TEST';
5. MyDatabase.SessionName := 'TEST';

If you now click on the dropdown field "Database" in MyDatabase it
*must* show the available databases.
Please check these steps.

Uli
Thu, Aug 27 2009 3:20 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Brent,

<< I'm probably doing something silly here, but I can't figure it out. I
want to open an EDBConfig.EDBCFG and get a list of databases. >>

GetDatabaseNames only returns the names (DatabaseName property) of any
TEDBDatabase components that have been created for the session.  What you
want is the GetDatabases() method:

http://www.elevatesoft.com/manual?action=mancompmethod&id=edb2&product=d&version=7&comp=TEDBSession&method=GetDatabases

However, in general, you should probably get used to directly querying the
Configuration system tables for such information:

http://www.elevatesoft.com/manual?action=mantopic&id=edb2sql&category=3&topic=39

--
Tim Young
Elevate Software
www.elevatesoft.com

Sat, Aug 29 2009 6:00 PMPermanent Link

Brent
Uli & Tim,
  Thanks guys, that worked! Smile

Brent
Image