How do I check connection status in data bound forms?
Posted on 2011-03-04
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:
textBox1.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.credentialsBindingSource, "FirstName", true));
Any help is greatly appreciated…