Null & DBNULL Problems

  • Thread starter Thread starter MadCrazyNewbie
  • Start date Start date
M

MadCrazyNewbie

Hey Group,

Just another quick question:

I have the following bit of code:

Private Sub cboPasswordListsDepartment_SelectedIndexChanged(ByVal sender
As Object, ByVal e As System.EventArgs) Handles
cboPasswordListsDepartment.SelectedIndexChanged
Me.BindingContext(dsPasswordList, "PasswordList").EndCurrentEdit()
If Me.BindingContext(dsPasswordList, "PasswordList").Position <> -1
And Not mlLoading Then

dsPasswordList.PasswordList.Rows(Me.BindingContext(dsPasswordList,
"PasswordList").Position).Item("DepartmentID") =
Me.cboPasswordListsDepartment.SelectedValue
End If
End Sub

When I try and Add something to my Datatset the above errors saying

An unhandled exception of type 'System.ArgumentException' occurred in
system.data.dll
Additional information: Cannot set Column 'DepartmentID' to be null. Please
use DBNull instead.

On this Line:
dsPasswordList.PasswordList.Rows(Me.BindingContext(dsPasswordList,
"PasswordList").Position).Item("DepartmentID") =
Me.cboPasswordListsDepartment.SelectedValue

Im so lost:( Has anybody got any ideas?

Many Thanks Again
MCN
 
Simon,

I assume that it says that you did not set the valuemember of the combobox
to the right property.

When I see it right, than it is now giving when selected a "nothing"
(empty) value.

Have a look at the setting to that valuemember from that combobox.

I hope this helps?

Cor
 
Cor,

Many Thanks for your reply, sorry i don`t know if its in regards to the
ComboBox or not.

The only error I get is :

An unhandled exception of type 'System.ArgumentException' occurred in
system.data.dll
Additional information: Cannot set Column 'DepartmentID' to be null.Please
use DBNull instead.

When you say look at the Value Member what should i be looking out for?

It does this on everyone of my forms? so theres about 40 ComboBox`s, have I
set something up Wrong?

Many Thanbks
MCN
 
Simon,

I have looked what you are doing, you are trying to get without setting a
relation to use two different tables in a combobox. I do not know if that
approach is working (I do not believe it) because you are saying nothing
about it in your select where you are reading two seperated tables.

When you want you can take the same approach as with the documents or create
a datarelation, however I never did it using this (however I would not know
why it should not go).

Because this is again an simple small database I would take for this the
rowfilter again.

I hope this helps,

Cor
 
Hi Cor,

This seemed to work OK but then something changed, i`ve been looking at some
old code i had saved and noticed it didn`t have the:

'Reset Combo Box`s - Select Index Twice due to M$ Bug
cboArcirisUsersPrimaryBomAccess.Text = ""
cboArcirisUsersPrimaryBomAccess.SelectedIndex = -1
cboArcirisUsersPrimaryBomAccess.SelectedIndex = -1
cboArcirisUsersPrimarySite.Text = ""
cboArcirisUsersPrimarySite.SelectedIndex = -1
cboArcirisUsersPrimarySite.SelectedIndex = -1
cboArcirisUsersRoles.Text = ""
cboArcirisUsersRoles.SelectedIndex = -1
cboArcirisUsersRoles.SelectedIndex = -1

Code in, I removed this from my Current project and then it works ok. Any
Ideas why the above would cause a problem adding?

Cheers
MCN
 
Back
Top