How do you catch an error from a data bound entry screen

G

Guest

I have a data entry screen using controls bound through a bindingSource,
TableAdaptor and a BindingNavigator to move through the records.
When I have an data entry error (such as Null for a value) I get the
following error raised all the way to the App.Run command.
This is not a dataGridView, so I can not use that DataError event to catch it.

I have tried the BindingSource_DataError event, but that does not seem to
get fired.

There is no code (That I have written at least) that I can place a break
point on when I click the Previous button on the BindingNavigator which is
what I am doing just before the error occurs. To simulate the problem just
drag a table from your Data Sources list using the "Details" option not the
DataGridView. This will put the controls on the form and a BindingNavigator
at the top. Run the application, click on the "+" sign on the
BindingNavigator then just click the MovePrevious button without filling in
any fields. You should get an error on your App.Run command that says some
field can not be null.

The relevant stack trace is below:

at System.Data.DataColumn.CheckNullable(DataRow row)
at System.Data.DataTable.RaiseRowChanging(DataRowChangeEventArgs args,
DataRow eRow, DataRowAction eAction, Boolean fireEvent)
at System.Data.DataTable.SetNewRecordWorker(DataRow row, Int32
proposedRecord, DataRowAction action, Boolean isInMerge, Int32 position,
Boolean fireEvent, Exception& deferredException)
at System.Data.DataTable.InsertRow(DataRow row, Int32 proposedID, Int32
pos, Boolean fireEvent)
at System.Data.DataView.FinishAddNew(Int32 currentIndex, Boolean success)
at System.Data.DataRowView.EndEdit()
at System.Windows.Forms.CurrencyManager.EndCurrentEdit()
at System.Windows.Forms.CurrencyManager.ChangeRecordState(Int32
newPosition, Boolean validating, Boolean endCurrentEdit, Boolean
firePositionChange, Boolean pullData)
at System.Windows.Forms.CurrencyManager.set_Position(Int32 value)
at System.Windows.Forms.BindingSource.MovePrevious()
at System.Windows.Forms.BindingNavigator.OnMovePrevious(Object sender,
EventArgs e)


Any ideas where I can handle this error?

Gregory McCallum, MCSD
(e-mail address removed)
 
G

Guest

Is there anyone that uses databound controls (excluding the dataviewgrid)? I
can not see how anyone is able to create a data entry screen using bound
controls if you can not trap data errors. I have reported this problem to
Microsoft as a bug and still have not got a response from them.

There must be a way to stop the application from crashing by trapping the
data entry errors. Has anyone successfully done this?

-Gregory McCallum, MCSD
(e-mail address removed)
 
R

rtkeeling

I don't know if any other version of Visual Studio does this, but VS2K5
creates xsd (XML Schema) files for tables when you create DataSets with
it. I would guess that it does something similar when you drag and
drop data bound controls. Check your project directory to see if there
are any. You will be astounded at how much code gets created in
support of binding! That's a good place to start.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top