Saturday, March 24, 2012

Wait for query to complete?

I have a page that contains an external WYSIWYG editor control. Whenthe user clicks a "save" button, the code behind calls a function in acomponent DLL that simply reads the contents of the editor and writesit to a database. The page then reloads and (re)populates the editorwith the text written to the database.
The problem is that depending on system load, the page occasionallyreloads before the information has been committed to the database andsubsequently the text in the editor window is incomplete. Is there away of ensuring that the data has been completely written to thedatabase before reloading the page?
Why do you want to reload data from database? You have it in memory at server anyway.
If you insist to do it, do it on the same db connection you will receive correct result.
Ack! You're right of course and in actual fact, the code to read thedocument data from the database only executes when the page isn't beingposted back.Embarrassed [:$]
Doesn't explain why the editor contents seem to be getting corrupted after a post back though... any ideas?

Hi,

It is possible that you are trying to read data before it was commited (for example in case you are using connection pooling).
I'll have to see some code to speculate more :)

0 comments:

Post a Comment