How do I check connection status in data bound forms?
I have a simple form in my .Net application: form with a combobox and textboxes bound to a SQL database. The user can browse data records by changing the combobox selection and print the select record.
When the application is idle for a longer period the DB drops the connection. Later when the user comes back and makes a quick selection change the data is not being supplied quickly enough to the text boxes. Clicking the print button, the application sends data from the previously selected record to the print function without any error messages (although at that time the combobox has different ID selected (before the DB connection is reestablished).
How can I check the DB connection status and catch this error?
The textboxes are bound with the following command:
Why not disable the print until the data is refreshed?
sonetinc
ASKER
How do I check if the data has been refreshed?
sonetinc
ASKER
I could be polling the textboxes for a change... which denitely is not a clean solution. There must be a better way.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
UnifiedIS
Does the combo box force a postback? Are you saying they change the combo value and click print before the postback occurs? And your print function prints what is in the controls as opposed to values from the database?
sonetinc
ASKER
This is a windows form... not asp.net. And yes... this is exactly what is happening. After a few seconds the connection to the DB is reestablished and all textboxes are updated with the corresponding values from the DB. While the connection is being reestablished the user can click the submit button and print with old values.
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.