Solved

vb datagridview with unbound column

Posted on 2013-12-04
3
392 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

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