CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2013

    Handling DataError

    I'm using an already existing database for my project, the data types are all set inside the access db, so I get the default DataGridView DataError every time I try to put something different in there. How do I replace the default message with something like 'Wrong data type' (that's the only exception I need to handle). If somebody could be so nice and explain it to me along with the whole 'handling a withevents variable' (I can't get that to work either).

  2. #2
    Join Date
    Jul 2001
    Sunny South Africa

    Re: Handling DataError

    You must look at Try and Catch blocks :


  3. #3
    Join Date
    Mar 2013

    Re: Handling DataError

    I made a simple application that can add/save/delete/search records in an access database. Each of the fields in the database had data type you can input specified inside the access file, and whenever I try to input something else, it gives me this lengthy error (There was an error in the DataGridView etc etc.) and tells me to 'handle the DataError exception' to replace it with a different message. I need to replace the default message with something else. Any chance you could help me with that? That's the best I could explain my problem.

  4. #4
    Join Date
    Jan 2006
    Fox Lake, IL

    Re: Handling DataError

    That's not how a DB is supposed to be designed, or work! Make a few different record (types or whatever) sharing a common key, and the store that as a secondary key to locate the first record.

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #5
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008

    Re: Handling DataError

    You were given the answer as to how to handle an exception in post number 2.
        'some code would be here that may trigger an exception
         'Some code would be here that will only execute if an exception occurs in the Try portion above
    End Try
    Always use [code][/code] tags when posting code.

Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.