By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,649 Members | 1,560 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,649 IT Pros & Developers. It's quick & easy.

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

P: n/a
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(DataRowChan geEventArgs 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.EndCurrentEdi t()
at System.Windows.Forms.CurrencyManager.ChangeRecordS tate(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.OnMovePrevio us(Object sender,
EventArgs e)
Any ideas where I can handle this error?

Gregory McCallum, MCSD
gm*******@honovi.com
Aug 18 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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
gm*******@honovi.com
"gmccallum" wrote:
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(DataRowChan geEventArgs 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.EndCurrentEdi t()
at System.Windows.Forms.CurrencyManager.ChangeRecordS tate(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.OnMovePrevio us(Object sender,
EventArgs e)
Any ideas where I can handle this error?

Gregory McCallum, MCSD
gm*******@honovi.com
Aug 22 '06 #2

P: n/a
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.

gmccallum wrote:
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
gm*******@honovi.com
"gmccallum" wrote:
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(DataRowChan geEventArgs 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.EndCurrentEdi t()
at System.Windows.Forms.CurrencyManager.ChangeRecordS tate(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.OnMovePrevio us(Object sender,
EventArgs e)
Any ideas where I can handle this error?

Gregory McCallum, MCSD
gm*******@honovi.com
Aug 22 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.