Board index » delphi » applyupdates/transactions

applyupdates/transactions

hi.

A couple of items below a dicusssion was held about using
applyupdates & transactions. I am experiencing the same kind of
problems but the discussion did not quite help me. So hear me out:

From a MDI form I can show a form which contains about 100
datacontrols, all bound to the same TQuery. This query can either be
in insert or edit mode (depending on a locate, done in my MDI onclick
menu handler). From this new form I can create another form which is
holding a stringrid. After closing this second form, I write the
contents of this grid to a couple of array's and my first form
receives the focus. If the OK button is clicked, the app should try
to post the contents of the datacontrols, and post the array's to
three different tables (using execsql). If anything should go wrong,
all postings should be canceled, but the state should still be either
dsedit or dsinsert.

The postings of the array's has a reference on fields posted from the
datacontrols.

I tried to start a transaction from my MDI menu onclick handler and a
cancel in my OK button click in my first form if an exception is
raised, or an commit if all goes well. Of course this works, but my
state is not dsInsert or dsEdit, it is dsBrowse. So if I correct my
mistake in the stringgrid, and hit OK again, an exception is raised
saying not in insert/edit state.

I tried this situ with cached updates but of course the same outcome.
Using TEdits etc. is not a good alternative considering there are
over 100 components.

I understand that starting a transaction outside my posting handler
is not good programming practice, but I have no clue what to do...
poetry..

Hope u can help!

Sander

 

Re:applyupdates/transactions


Hi Sander,

Have you tried setting the the query object to Edit before you try your
procedures?  Query.Edit?

--
Michael Glatz
mgl...@briefcase.com

Quote
Sander van Haaff wrote in message <01bdf91f$c85bbe40$d22979c3@CMG12345>...
>hi.

>A couple of items below a dicusssion was held about using
>applyupdates & transactions. I am experiencing the same kind of
>problems but the discussion did not quite help me. So hear me out:

>From a MDI form I can show a form which contains about 100
>datacontrols, all bound to the same TQuery. This query can either be
>in insert or edit mode (depending on a locate, done in my MDI onclick
>menu handler). From this new form I can create another form which is
>holding a stringrid. After closing this second form, I write the
>contents of this grid to a couple of array's and my first form
>receives the focus. If the OK button is clicked, the app should try
>to post the contents of the datacontrols, and post the array's to
>three different tables (using execsql). If anything should go wrong,
>all postings should be canceled, but the state should still be either
>dsedit or dsinsert.

>The postings of the array's has a reference on fields posted from the
>datacontrols.

>I tried to start a transaction from my MDI menu onclick handler and a
>cancel in my OK button click in my first form if an exception is
>raised, or an commit if all goes well. Of course this works, but my
>state is not dsInsert or dsEdit, it is dsBrowse. So if I correct my
>mistake in the stringgrid, and hit OK again, an exception is raised
>saying not in insert/edit state.

>I tried this situ with cached updates but of course the same outcome.
>Using TEdits etc. is not a good alternative considering there are
>over 100 components.

>I understand that starting a transaction outside my posting handler
>is not good programming practice, but I have no clue what to do...
>poetry..

>Hope u can help!

>Sander

Re:applyupdates/transactions


Sander,

If I'm understanding you right then you are using cached updates to post the
values into your database tables. If this is the case you should create an
OnUpdateError event handler for your query component, and deal with any
errors there. Once you've rolled-back your transactions you can call
DataSet.Edit (DataSet is passed as a parameter into the event handler for
you) at the end of the method. This should leave your dataset in edit mode
if any errors occurred.

Hope that is of some use.

Graeme J Hosking
gjhosk...@dial.pipex.com

Other Threads