Solved

vb datagridview with unbound column

Posted on 2013-12-04
3
395 Views
Last Modified: 2013-12-06
I have a datagridview in an application that displays open invoice amounts.  I'm storing data in an MS SQL database.  I created an unbound column for entry of payment amounts against an open invoice.  Upon "submitting" a process is run that applies the payment amount against the open invoice and this works fine.  However, if the user has entered an incorrect payment amount and hits delete to clear the field an exception is thrown, system.formatexception, "input string not in a correct format".  I have not been able to find a way to prevent this from happening.
0
Comment
Question by:GregorySinger
  • 2
3 Comments
 
LVL 34

Expert Comment

by:Paul MacDonald
ID: 39698378
The fix will depend on what you're using to determine the field has changed, but it appears you're looking at the value of the unbound field and failing when it's empty.  Trapping for an empty field and bypassing any activity requiring it to be populated would seem like the obvious thing to do.

Is it this unbound field the error refers to?  What are you trying to do with that value when the error occurs?
0
 

Author Comment

by:GregorySinger
ID: 39701069
Yes, it appears to be the origin of the error. I'd like to have a message
Box appear to alert the user. How to trap the error is the issue. TNX.
0
 
LVL 34

Accepted Solution

by:
Paul MacDonald earned 500 total points
ID: 39701395
Wrap the code in a Try...CatchTry...Catch.  

Unless the code is inline with the page you can't just pop up a message, but you can throw the error onto the page itself, or have the code e-mail you the error.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question