Results 1 to 6 of 6

Thread: [RESOLVED] Handling the DataError Event?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Resolved [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.
    Blake

  2. #2
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,600

    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.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  3. #3
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,206

    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.

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    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.
    Blake

  5. #5
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,600

    Re: Handling the DataError Event?

    Quote Originally Posted by blakemckenna View Post
    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.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    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.
    Blake

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width