|
-
Jan 10th, 2002, 05:20 PM
#1
Thread Starter
Junior Member
Data Form Wizard Woes
Hello - I'm currently trying to develop a small app to help me keep track of my eBay sales. I entered all data into excel, exported it to access and let the VB.NET data form wizard do the rest. It was working fine until I attempted to add a combo box. Now it throws:
An unhandled exception of type 'System.InvalidCastException'
occurred in mscorlib.dll
Additional information: Object cannot be cast from DBNull to other types.
This exception is thrown after the "Add" button is pressed, which used to just add a new row to the database upon which I could add my data. Does this ring any bells with anyone?? Any help would be MUCH appreciated!!
Thank you!
Sincerely,
Reid V. Plumbo
[email protected]
-
Jan 11th, 2002, 05:08 AM
#2
can you post the code the wizard generated for this event please ?
-
Jan 11th, 2002, 09:46 AM
#3
Thread Starter
Junior Member
Code
Thank you! Tell me if you need more code than this, or if you'd just like the entire project mailed to you. THANK YOU!
Private Sub mfp_btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mfp_btnAdd.Click
Try
'Clear out the current edits
Me.BindingContext (objmyTransactions, "Transactions").EndCurrentEdit()
'It breaks on this next line.
Me.BindingContext(objmyTransactions, "Transactions").AddNew()
Catch eEndEdit As System.Exception
System.Windows.Forms.MessageBox.Show(eEndEdit.Message)
End Try
Me.objmyTransactions_PositionChanged()
End Sub
-
Mar 20th, 2004, 06:03 PM
#4
Lively Member
The problem is caused from binding certain types of controls that can't display DBNull values properly, to the dataset. Two examples are the DateTimePicker, and the Checkbox. Here is an MSDN article that describes the problem:
http://support.microsoft.com/default.aspx?scid=kb;en-us;313513
I was having the same error and found that in my case, it was a Checkbox. I didn't use the solution provided in the MSDN article. I just made sure that the field in the dataset that the checkbox was bound to was not null before doing the "resumebinding" command on the binding context object (or in your case, AddNew).
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
|