Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 10 total
Thread Problem connecting to database in XE
Tue, Oct 25 2011 7:07 PMPermanent Link

Colin Wood

VirtualTec P/L

Hi,
I've built a small app which successfully creates a EDB database on a local drive.  I've used sql code to create the database and have been able to populate the database with data.  

My problem is that when trying to connect to this now existing database from within Delphi XE, the Engine and Session seem to be ok, but when I try to connect the tEDBDatabase component I get the #401 error saying the database does not exist.  The UNC path set in the engine is correct.  I've typed in the DatabaseName and Database using the same names as I used in the code, but I noticed that the Database drop-down box does not display the created database.

I've followed the instructions for setting up the Engine and Session according to the EDB manual. But I'm not sure why it will not connect.  Any suggestions would be appreciated.
Colin
Wed, Oct 26 2011 2:36 AMPermanent Link

Uli Becker

Colin,

> I've followed the instructions for setting up the Engine and Session according to the EDB manual. But I'm not sure why it will not connect.  Any suggestions would be appreciated.
> Colin

You should double check:

1. The ConfigPath of the engine has to be the same as the path you used
when creating the database.
2. SessionName of EDBSession set?
3. SessionNAme of EDBDatabase set?

Then you should see your database(s) in the OI.

Uli
Wed, Oct 26 2011 5:16 AMPermanent Link

Colin Wood

VirtualTec P/L

Uli Becker wrote:
You should double check:

1. The ConfigPath of the engine has to be the same as the path you used
when creating the database.
2. SessionName of EDBSession set?
3. SessionNAme of EDBDatabase set?

Then you should see your database(s) in the OI.

Uli

Hi Uli

Yep, I've checked those things. But still no joy.  
Is there any way of looking at the database structure from a third party app (something like DBISAM's Data System Utility), to see if I have done something wrong when creating the database structure?

I've looked at the ElevateDB Manager but it seems to only allow the creation of databases, not a connection to an existing one.  Having said that, I don't really think that is where the problem is.  

I've removed the 3 elevateDB components and then placed them on the form again, just in case I changed some property that I shouldn't have touched.  But that didn't make any difference.  Seems to me that I should just work, but won't. Sigh!
Wed, Oct 26 2011 6:19 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Colin


EDBManager does allow you to view existing databases as well as creating them. If you've moved from DBISAM then you have the "joy of learning" ahead of you Smiley

ElevateDB works in a very different way to DBISAM.

Starting with EDBManager:

open EDBManager
- select Create New Session
- a dialog will open up
-    on the General page give the session a name
-    since you said its a local database on the Local page set the directory where the session is to be created (this may be the same as where the database is located but its better not to be)
-    unless you created the database with a different user name / password enter Administrator and EDBDefault on the Login page
-    SAVE IT

Open the session - drill down to databases, select Create new database. This isn't really creating a database its just pointing to where one is or may be created. A dialog will open up enter the name for the database and the folder in which it will be created.

Open the database you've just created. At this point EDBManager will 1) create the directory if needed 2) if needed create a catalog file and a lock file in the directory.

If you already have a database in the directory that will be used and you will be able to see the tables if you drill down to them. If not you can create tables using the dialogs.

In your application you will need the following on a form:

TEDBEngine
TEDBSession
TEDBDatabase
TEDBTable(s) or
TEDBQuery(s)

The TEDBEngine has one setting you'll need to change - UseLocalSessionEngineSettings. That tells the engine to pick up its settings from the session component otherwise it uses its own.

In TEDBSession you'll need to set

LocalConfigPath - this is where the configuration file lives NOT where the database lives. The configuration file will then tell the engine where the database is.

SessionName - I find it easier to set my own rather than use AutoSessionName

LoginUser & LoginPassword - unless you've set up users these will be Administrator and EDBDefault

In TEDBDatabase you'll need to set

firstly the SessionName you set above, the DatabaseName (make one up - I use DB) and if you've done everything right so far select Database from drop down list.

TEDBTable you set SessionName, DatabaseName and select the TableName from the drop down list

TEDBQuery set SessionName & DatabaseName

You should now be in business. If not The getting started section of the manual is pretty good.


Roy Lambert [Team Elevate]
Wed, Oct 26 2011 7:25 AMPermanent Link

Colin Wood

VirtualTec P/L

Thanks for the advice on the EDB manager Roy.  I get how that works now.

I've followed through your list of to-dos re the Engine, Session, Database, but still haven't got it working.
You mentioned that the LocalConfigPath is where the configuration file lives not where the database lives. In that case how is the configuration file told where the database resides?

When I used the command...
     Execute('CREATE DATABASE "STYDb" PATH ' + Quote(gDataDirectory) +
             ' DESCRIPTION ''STY Database''');

Did that embed the path into the config file, or is it done in another way?

Col
Wed, Oct 26 2011 9:01 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Colin


>Thanks for the advice on the EDB manager Roy. I get how that works now.

Good

>I've followed through your list of to-dos re the Engine, Session, Database, but still haven't got it working.
>You mentioned that the LocalConfigPath is where the configuration file lives not where the database lives. In that case how is the configuration file told where the database resides?
>
>When I used the command...
> Execute('CREATE DATABASE "STYDb" PATH ' + Quote(gDataDirectory) +
> ' DESCRIPTION ''STY Database''');
>
>Did that embed the path into the config file, or is it done in another way?

Nope that's exactly what puts the path to the database into the config file.

Opening or carrying out any action on the session component will result in the config file being created in whatever directory it happens to be pointing to at the time.

To try and understand where you problem is can you try dropping the components on a form and opening them one at a time. This means setting Active to True for the engine and Connected to True for the session and database. Let me know hat errors you get from which component.

Roy Lambert [Team Elevate]
Wed, Oct 26 2011 9:24 AMPermanent Link

Colin Wood

VirtualTec P/L

Ok, it suddenly seems to have started working.  I hadn't set the UseLocalSessionEngineSession to true until your previous instruction.  However when I then used the drop-down TEDBdatabase.database it still displayed no items.  Now it seems to have found the database - and all is well Smile
Thanks for persevering with me. At least I now feel that I understand a bit more about what is happening with the database.
Regards
Col
Wed, Oct 26 2011 9:38 AMPermanent Link

Raul

Team Elevate Team Elevate

Colin,

I know you got everything working but in case you have not done it yet i would suggest doing the local app tutorial from manual as it walks you thru EDBManager and basic app process, including important component properties:

http://www.elevatesoft.com/manual?action=topics&id=edb2&product=rsdelphiuni&version=XE&section=local_application_tutorial

There is also c/s one :http://www.elevatesoft.com/manual?action=topics&id=edb2&product=rsdelphiuni&version=XE&section=client-server_application_tutorial

Raul
Wed, Oct 26 2011 11:16 PMPermanent Link

Colin Wood

VirtualTec P/L

Thanks for the suggestion Raul.  I'll certainly have a read.
Col
Mon, Oct 31 2011 8:15 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Colin,

<< Ok, it suddenly seems to have started working.  I hadn't set the
UseLocalSessionEngineSession to true until your previous instruction.
However when I then used the drop-down TEDBdatabase.database it still
displayed no items.  Now it seems to have found the database - and all is
well SmileThanks for persevering with me. At least I now feel that I
understand a bit more about what is happening with the database. >>

A problem where a database is created using CREATE DATABASE, but cannot be
found, is always a case of an incorrect configuration file path setting.

Whenever you have this type of issue, a good rule-of-thumb is to search your
local drive for any edbconfig.edbcfg files.  That will give you an idea of
where the various sessions (Delphi, EDB Manager) are creating their
configuration files, and whether they are all pointing to the same physical
location.  Once you have all of the various actors using the same
configuration file path, then you can be assured that they will also all
have the same physical database location.

--
Tim Young
Elevate Software
www.elevatesoft.com
Image