473,386 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Null & DBNULL Problems

Hey Group,

Just another quick question:

I have the following bit of code:

Private Sub cboPasswordListsDepartment_SelectedIndexChanged(By Val 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
Nov 21 '05 #1
4 5164
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
Hey Group,

Just another quick question:

I have the following bit of code:

Private Sub cboPasswordListsDepartment_SelectedIndexChanged(By Val 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

Nov 21 '05 #2
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

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:uy**************@TK2MSFTNGP12.phx.gbl...
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
Hey Group,

Just another quick question:

I have the following bit of code:

Private Sub cboPasswordListsDepartment_SelectedIndexChanged(By Val

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


Nov 21 '05 #3
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


"MadCrazyNewbie" <te**@nospam.com> schreef in bericht
news:GC********************@karoo.co.uk...
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

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:uy**************@TK2MSFTNGP12.phx.gbl...
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
Hey Group,

Just another quick question:

I have the following bit of code:

Private Sub cboPasswordListsDepartment_SelectedIndexChanged(By Val

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



Nov 21 '05 #4
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

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:OV**************@TK2MSFTNGP11.phx.gbl...
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


"MadCrazyNewbie" <te**@nospam.com> schreef in bericht
news:GC********************@karoo.co.uk...
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

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:uy**************@TK2MSFTNGP12.phx.gbl...
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

> Hey Group,
>
> Just another quick question:
>
> I have the following bit of code:
>
> Private Sub cboPasswordListsDepartment_SelectedIndexChanged(By Val 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
>
>



Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: MP | last post by:
Hello, I am trying to write a class that will expose some properties. One of the property is extracted from a SQL database and can be NULL or some integer value. Is there a elegant way of...
0
by: Daniel Zelisko | last post by:
Hello Could anyone tell me how to send a null decimal value to the sql server depending on its value? The following code gives me an error: System.Data.SqlTypes.SqlNullValueException: Data is...
6
by: Randy Rubin | last post by:
How do I handle Testing for null values in a database? Here is a Line of Code: If Not jNull("JNum") Is DBNull Then And this is the Error: BC30684: 'DBNull' is a type and cannot be used as...
1
by: excelleinc.com | last post by:
Hi, I'm trying to check if field contains NULL value in MSSQl 2000 database but keep receiving error. asp.net code: If Trim(HLSQLDSet.Tables("mfglinks").Rows(15).Item(0)) Is Null Then...
1
by: Calvin KD | last post by:
Hi everyone, Can someone show me how to display an empty string in a boundcolumn of a datagrid when the data source item is NULL. Datagrid by default displays the and that's BAD!!!!! I've tried...
15
by: TC | last post by:
What does it mean for an integer to have a null value? I am trying to use the DataView.Find method. That method has an integer return type which contains the "index of the row in the DataView...
9
by: GotDotNet? | last post by:
I have a dataset and I have to loop through it and some of the values for an insertition into the db. Some of the fields are integers and booleans but contain a NULL in the field. how can I...
2
by: Problematic coder | last post by:
Here is the code: 64 If objdr.Item("BD") = "" Or objdr.Item("BD") Is DBNull.Value Then 'test to see if result is blank or null 65 strBD = "00000000" 'No birthdate found so set to 8...
10
by: =?Utf-8?B?R3JlZw==?= | last post by:
I have the following three files. 1. Users.aspx is a webpage that uses the <asp:ObjectDataSourcecontrol to populate a simple <asp:ListBoxcontrol. 2. The UserDetails.cs file creates a Namespace...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.