-
Nov 16th, 2017, 11:45 AM
#1
Thread Starter
PowerPoster
[RESOLVED] Handling the DataError Event?
I have a Windows Form that contains a DataGridView. This grid is populated via a Stored Procedure. It contains 5 columns, of which column 3 is NULL because it allows for the User to input data. The problem that's occurring is when a User types data into this column and hits the <enter> key, an exception is thrown in the DataError Event (see image). Does anyone know why this happens. Again, column 3 returns a NULL value from the SPROC.
-
Nov 16th, 2017, 03:01 PM
#2
Re: Handling the DataError Event?
As far as I can see, one of the values returned from the Stored Procedure wants to go into a cell of the DataGridView which is only willing to accept values that can be reliably converted to numbers.
-
Nov 16th, 2017, 03:01 PM
#3
Re: Handling the DataError Event?
Just guessing but two things come to mind when looking at that error.
What is the data type of that field in the database and does the input match.
Have you setup some type of formatting in the DGV or database.
-
Nov 16th, 2017, 04:43 PM
#4
Thread Starter
PowerPoster
Re: Handling the DataError Event?
The DGV is bound to the datatable returned by the SPROC, so there is no implicit column definitions with datatypes and there is is no custom formatting in the SPROC or in the CellFormatting Event for the DGV.
-
Nov 16th, 2017, 04:59 PM
#5
Re: Handling the DataError Event?
Originally Posted by blakemckenna
The DGV is bound to the datatable returned by the SPROC, so there is no implicit column definitions with datatypes and there is is no custom formatting in the SPROC or in the CellFormatting Event for the DGV.
Well it's obvious from that exception that the DGV is trying to format a value. You need to investigate and find out which value is causing that error.
-
Nov 16th, 2017, 08:19 PM
#6
Thread Starter
PowerPoster
Re: Handling the DataError Event?
I found the issue. My SPROC was retrieving a field that has NULL values in but my DGV was not dealing with it. I removed the NULL field from the SPROC (it wasn't being used anyway) and that seemed to work.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|