Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 12 total
Thread Switching Session in a program
Wed, Oct 21 2020 5:33 AMPermanent Link

Adam Brett

Orixa Systems

I have spent about 15 years writing Delphi programs with EDB. All this time I have been writing applications that address a single database. My program starts, logs on ... end of.

Now I have users with several Apps, doing different things, and with local / remote databases.

I am writing a utility to allow them to work with them, a cut down EDB Manager, essentially.

This new program needs to be able to chop and change data-connections.

I am making calls which close and free all data-components when I make the change (so far as I can tell) but when I open the connection to the new database-session I get the error message "Session Name <OldSession> is not valid".

I don't know what object in my program is raising this error.

Any pointers on how I can fix it?
Wed, Oct 21 2020 6:27 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Adam


I'm guessing that you're allowing ElevateDB to auto create the session names. If so you could write your own session naming code which would allow you to spot which one is left over.

The other thing that suggests itself to me is try closing the engine and then reopening it - that should dispose of everything.

For me I usually get that error in the IDE when I double click a table to bring up a list of fields and the datamodule with the engine etc on hasn't been opened so look at what gets opened just after the change of database.

Roy Lambert
Wed, Oct 21 2020 9:22 AMPermanent Link

Raul

Team Elevate Team Elevate

On 10/21/2020 5:33 AM, Adam Brett wrote:
> I am making calls which close and free all data-components when I make the change (so far as I can tell) but when I open the connection to the new database-session I get the error message "Session Name <OldSession> is not valid".
>
> I don't know what object in my program is raising this error.

To add to what Roy said this error is triggered by the engine when it is
trying to find a session by name - if one is not found then "session
name is invalid" is generated.

I would make sure you manually open session first to ensure all
connection params are properly set and not open database or even
table/query which can auto-trigger session to open with possibly invalid
settings.

Raul

Thu, Oct 22 2020 5:43 AMPermanent Link

Adam Brett

Orixa Systems

Thanks Roy and Raul.

Really useful suggestions.

I found a couple of random helper forms which included data-components I had forgotten about & not reset ... argh!
Thu, Oct 22 2020 6:50 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Adam


Just think how difficult it would have been if they hadn't been "helper forms"

Roy Lambert
Thu, Oct 22 2020 6:56 AMPermanent Link

Adam Brett

Orixa Systems

Actually: Is there a mechanism in EDB to reference _every_ connection in an Application?

I can see TEDBDatabase.Datasets, which includes a SessionName property. I guess this will do it.
Thu, Oct 22 2020 8:44 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Adam

>Actually: Is there a mechanism in EDB to reference _every_ connection in an Application?
>
>I can see TEDBDatabase.Datasets, which includes a SessionName property. I guess this will do it.

I'm not to sure about that - from the manual

<<The DataSets property provides an indexed array of all active datasets for a TEDBDatabase component.
An active dataset is one that is currently open.>>

The key word is "active". Your problem occurred because your application tried to open an inactive dataset with an invalid session name. Then you could also have the problem of TEDBSession components having their name assigned at runtime (I do this in threads, but not often in the main thread).

Maybe Tim could add the name of the component that raises the session name not valid error to the error?

Looking at the source in edbcomps I can't spot anywhere Frown


Roy
Thu, Oct 22 2020 9:09 AMPermanent Link

Raul

Team Elevate Team Elevate

On 10/22/2020 6:56 AM, Adam Brett wrote:
> Actually: Is there a mechanism in EDB to reference _every_ connection in an Application?
>
> I can see TEDBDatabase.Datasets, which includes a SessionName property. I guess this will do it.

I would do it top down in recursive (or nested for loops)

EDB Engine has Sessions property which allows you to access every
session (simple loop using SessionCount)

https://www.elevatesoft.com/manual?action=viewprop&id=edb2&product=rsdelphiwin32&version=10.4&comp=TEDBEngine&prop=Sessions

and then for every session you can loop thru databases

https://www.elevatesoft.com/manual?action=viewprop&id=edb2&product=rsdelphiwin32&version=10.4&comp=TEDBSession&prop=Databases


and finally for every database loop thru datasets

https://www.elevatesoft.com/manual?action=viewprop&id=edb2&product=rsdelphiwin32&version=10.4&comp=TEDBDatabase&prop=DataSets


Datasets at this point will be queries, tables, etc

It's pretty simple to write something for example that closes it all
from "bottom up".

Raul
Thu, Oct 22 2020 10:52 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Raul


<<It's pretty simple to write something for example that closes it all
from "bottom up".>>


Yes, but why bother - just closing the engine should close everything else.

Roy Lambert
Thu, Oct 22 2020 12:42 PMPermanent Link

Raul

Team Elevate Team Elevate

On 10/22/2020 10:52 AM, Roy Lambert wrote:
>
> <<It's pretty simple to write something for example that closes it all
> from "bottom up".>>
>
>
> Yes, but why bother - just closing the engine should close everything else.
>

If all you want to do is close then possibly yes but closing engine is
bit of a sledgehammer approach.

I have found that managing your sessions/db/datasets long term is lot
more maintenable - especially if you want to close and then open or
maybe have different sessions mixed etc

Raul
Page 1 of 2Next Page »
Jump to Page:  1 2
Image