Subject Re: [IBO] Re: Updating master detail tables - 2nd post
Author Terry Black
Hi, thanks for the information. You have provided me with a range of
things that I need to change.

Thanks again for your help.

Terry

>>> "dr_john_mp" <dr.john@...> 01/06/11 4:59 PM >>>
Hi

When developing an application its not uncommon to manually open an SQL
component to see the results in a table (e.g. to order/format the
columns). As noted you need to make sure that you close sql's, set
connected=FALSE on any database components and active=false on any
clientdatasets as soon as possible, and certainly before releasing the
program. That said, if you don't the result is that your program may
not run (because the form create will try and connect to your
development database, which may not be available to 'normal' users) - I
have never seen this stop the program from compiling.

The error you are reporting is a run-time error not a failure to
compile. I suspect you have the database set as connected in the object
inspector and at run time are trying to set the database parameters
(database name, user name, etc) which you cannot do while it is
connected.

Your comment about transactions is possibly to do with the way you
handle database errors. if while debugging you stop the application
mid-transaction, and then restart it and attempt to change a record
locked by the still open transaction you are likely to get an error.
depending on the database version and mode, a short network disconnect
while you reboot your PC may not be enough for the database to recognise
that you have aborted the original connection.

you need to make sure all your sql's are in a try/except block with a
rollback in the except and avoid aborting the application before it has
done the rollback on any errors.

since you have more than one program accessing the database I assume you
have code to handle momentary conflicts.


--- In IBObjects@yahoogroups.com, Robert Martin <rob@...> wrote:
>
> Hi
>
> I suspect it is what Daniel suggested. At design time you are setting

> Connected to true. I dont use the IB_ components but I suspect it
works
> the same as the IBO components. Most likely this is accidental, if
you
> mannually change the property to true it can cause this error, but
> bringing up field / property editors on Query / table components will
> automatically set connected to true. This will cause your error.
>
> All you need do to get around this is to have code that always makes
> sure connected = false before attempting to connect. Also remember to

> make sure connected = false before doing a release build. Otherwise
> when you app starts it will try and connect to your dev DB which may
not
> be in the same location / Alias on your clients machine.
>
> Hope this helps
> Rob
>
>
> On 1/06/2011 11:02 a.m., Terry Black wrote:
> > Hi, I have 2 Delphi applications that are working on the one
Firebird
> > database. Let me explain. The first application uses 3 tables
> > relationally linked to each other. It is a many to many
relationship.
> > This application has been working well for 6 months. The second
> > application is my developmental application which uses the same
firebird
> > database which is looking at adding records to the 3 tables. So I am
> > constantly changing and compiling the second developmental
application.
> > At some stage it hangs and then fails to compile. Giving me the
> > 'EIB_ConnectionError - Cannot change while connected'.
> > I can still use the original application which uses the same
database.
> >
> > If I rebooted the computer my developmental application would still
not
> > compile. So this looked like there was something wrong with my code
in
> > the developmental application. However, I find this morning that it
> > compiles easily. I have not changed anything since it was unable to
> > compile yesterday.
> >
> > I am not sure what is happening. It looks like I opened a
transaction
> > which for some reason would not close yesterday. This prevented my
> > developmental ap> >
> > Terry
> >
> >
> >
> >>>> Daniel Rail<daniel@...> 31/05/2011 10:00 pm>>>
> > Hi,
> >
> > At May-31-11, 4:26 AM, Svein Erling TysvÃ|r wrote:
> >
> >> I think she meant that she thinks you're doing something like:
> >> TIB_Connection1.Connect;
> >> TIB_Connection1.Username:=...
> >> and you cannot change username or password when you're already
> >> connected. Actually, I don't think it has to be username or
password
> >> that is changing, I think it can also be that you try to change the
> >> name of the database, maybe even the name of a database belonging
to
> >> a started transaction (at least I doubt it is possible to close a
> >> connection whilst its transaction is running).
> >> You have to find the exact place in your code that causes the
> >> error, this kind of showstoppers luckily tend to be relatively easy
> >> to locate (and easy to understand why gives this error once you
find
> > the exact line).
> >
> > It might also be that TIB_Connection.Connected := True at compile
> > time, and then trying to change the server and path at runtime.
> >
>




Disclaimer: Unless explicitly attributed, the opinions expressed in this
email are those of the author only and do not represent the official
view of Northern Sydney Central Coast Health nor the New South Wales
Government.