Subject | Re: [IBO] "Statement has not been prepared" |
---|---|
Author | tickerboo2002 |
Post date | 2002-09-23T13:55:49Z |
Helen
The qry is always prepared. In FormShow, I prepare the qry. Do I
have to prepare again, for when the qry uses the sql (Insert, update,
Delete) on the UpdateSQL tab of the query editor?
My FormCloseQuery event now looks like this:
ShowTransactionState()
if ( qry->NeedToPost )
{
qry->Post();
if ( qry->IB_Transaction->InTransaction )
qry->IB_Transaction->Commit();
}
qry->Close();
if ( qry->Prepared )
qry->Unprepare();
At the top of this event (ShowTransactionState) I print out the state
of the Transaction:
InTransaction: false
Started: true
TransactionIsActive: false
TransactionState: tsInactive
Further testing reveals the following:
If I put the above code into an OnButtonClick, the code works OK with
no "Statement has not been prepared", but the same code in
FormCloseQuery gives the "Statement has not been prepared" error.
I'm starting to think BCB is giving me the run around.
Also, (with the code in the FormCloseQuery event)When the user has
finished editing an item, I locate the row in the dataset using:
TIB_LocateOptions lo;
if ( qry->Locate( "USER_TASKS_ID", nTaskId, lo ))
{
// In my test case, I've commented the update code out
}
It seems that 'Locate' causes the "Statement has not been prepared"
error. If I don't use Locate, then I don't get the error. Using
Locate, even though I don't change the fields gives the error when
the data is eventually commited and the form closed.
Also the error appears after I've done all the post/commit/unprepare
stuff, it seems to pop up when the TIB_Transaction & TIB_Query are
being deleted with the form.
....thinking of jumping out the window
David
> Well, you can't Unprepare a statement that hasn't been prepared,can you?
The qry is always prepared. In FormShow, I prepare the qry. Do I
have to prepare again, for when the qry uses the sql (Insert, update,
Delete) on the UpdateSQL tab of the query editor?
My FormCloseQuery event now looks like this:
ShowTransactionState()
if ( qry->NeedToPost )
{
qry->Post();
if ( qry->IB_Transaction->InTransaction )
qry->IB_Transaction->Commit();
}
qry->Close();
if ( qry->Prepared )
qry->Unprepare();
At the top of this event (ShowTransactionState) I print out the state
of the Transaction:
InTransaction: false
Started: true
TransactionIsActive: false
TransactionState: tsInactive
Further testing reveals the following:
If I put the above code into an OnButtonClick, the code works OK with
no "Statement has not been prepared", but the same code in
FormCloseQuery gives the "Statement has not been prepared" error.
I'm starting to think BCB is giving me the run around.
Also, (with the code in the FormCloseQuery event)When the user has
finished editing an item, I locate the row in the dataset using:
TIB_LocateOptions lo;
if ( qry->Locate( "USER_TASKS_ID", nTaskId, lo ))
{
// In my test case, I've commented the update code out
}
It seems that 'Locate' causes the "Statement has not been prepared"
error. If I don't use Locate, then I don't get the error. Using
Locate, even though I don't change the fields gives the error when
the data is eventually commited and the form closed.
Also the error appears after I've done all the post/commit/unprepare
stuff, it seems to pop up when the TIB_Transaction & TIB_Query are
being deleted with the form.
....thinking of jumping out the window
David