473,770 Members | 1,629 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Null & DBNULL Problems

Hey Group,

Just another quick question:

I have the following bit of code:

Private Sub cboPasswordList sDepartment_Sel ectedIndexChang ed(ByVal sender
As Object, ByVal e As System.EventArg s) Handles
cboPasswordList sDepartment.Sel ectedIndexChang ed
Me.BindingConte xt(dsPasswordLi st, "PasswordList") .EndCurrentEdit ()
If Me.BindingConte xt(dsPasswordLi st, "PasswordList") .Position <> -1
And Not mlLoading Then

dsPasswordList. PasswordList.Ro ws(Me.BindingCo ntext(dsPasswor dList,
"PasswordList") .Position).Item ("DepartmentID" ) =
Me.cboPasswordL istsDepartment. SelectedValue
End If
End Sub

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

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

On this Line:
dsPasswordList. PasswordList.Ro ws(Me.BindingCo ntext(dsPasswor dList,
"PasswordList") .Position).Item ("DepartmentID" ) =
Me.cboPasswordL istsDepartment. SelectedValue

Im so lost:( Has anybody got any ideas?

Many Thanks Again
MCN
Nov 21 '05 #1
4 5181
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 cboPasswordList sDepartment_Sel ectedIndexChang ed(ByVal sender As Object, ByVal e As System.EventArg s) Handles
cboPasswordList sDepartment.Sel ectedIndexChang ed
Me.BindingConte xt(dsPasswordLi st, "PasswordList") .EndCurrentEdit ()
If Me.BindingConte xt(dsPasswordLi st, "PasswordList") .Position <> -1 And Not mlLoading Then

dsPasswordList. PasswordList.Ro ws(Me.BindingCo ntext(dsPasswor dList,
"PasswordList") .Position).Item ("DepartmentID" ) =
Me.cboPasswordL istsDepartment. SelectedValue
End If
End Sub

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

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

On this Line:
dsPasswordList. PasswordList.Ro ws(Me.BindingCo ntext(dsPasswor dList,
"PasswordList") .Position).Item ("DepartmentID" ) =
Me.cboPasswordL istsDepartment. 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.Argumen tException' 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**********@p lanet.nl> wrote in message
news:uy******** ******@TK2MSFTN GP12.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 cboPasswordList sDepartment_Sel ectedIndexChang ed(ByVal

sender
As Object, ByVal e As System.EventArg s) Handles
cboPasswordList sDepartment.Sel ectedIndexChang ed
Me.BindingConte xt(dsPasswordLi st, "PasswordList") .EndCurrentEdit () If Me.BindingConte xt(dsPasswordLi st, "PasswordList") .Position

<> -1
And Not mlLoading Then

dsPasswordList. PasswordList.Ro ws(Me.BindingCo ntext(dsPasswor dList,
"PasswordList") .Position).Item ("DepartmentID" ) =
Me.cboPasswordL istsDepartment. SelectedValue
End If
End Sub

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

An unhandled exception of type 'System.Argumen tException' occurred in
system.data.dll
Additional information: Cannot set Column 'DepartmentID' to be null.

Please
use DBNull instead.

On this Line:
dsPasswordList. PasswordList.Ro ws(Me.BindingCo ntext(dsPasswor dList,
"PasswordList") .Position).Item ("DepartmentID" ) =
Me.cboPasswordL istsDepartment. 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.co m> schreef in bericht
news:GC******** ************@ka roo.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.Argumen tException' 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**********@p lanet.nl> wrote in message
news:uy******** ******@TK2MSFTN GP12.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 cboPasswordList sDepartment_Sel ectedIndexChang ed(ByVal

sender
As Object, ByVal e As System.EventArg s) Handles
cboPasswordList sDepartment.Sel ectedIndexChang ed
Me.BindingConte xt(dsPasswordLi st,

"PasswordList") .EndCurrentEdit () If Me.BindingConte xt(dsPasswordLi st, "PasswordList") .Position

<> -1
And Not mlLoading Then

dsPasswordList. PasswordList.Ro ws(Me.BindingCo ntext(dsPasswor dList,
"PasswordList") .Position).Item ("DepartmentID" ) =
Me.cboPasswordL istsDepartment. SelectedValue
End If
End Sub

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

An unhandled exception of type 'System.Argumen tException' occurred in
system.data.dll
Additional information: Cannot set Column 'DepartmentID' to be null.

Please
use DBNull instead.

On this Line:
dsPasswordList. PasswordList.Ro ws(Me.BindingCo ntext(dsPasswor dList,
"PasswordList") .Position).Item ("DepartmentID" ) =
Me.cboPasswordL istsDepartment. 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
cboArcirisUsers PrimaryBomAcces s.Text = ""
cboArcirisUsers PrimaryBomAcces s.SelectedIndex = -1
cboArcirisUsers PrimaryBomAcces s.SelectedIndex = -1
cboArcirisUsers PrimarySite.Tex t = ""
cboArcirisUsers PrimarySite.Sel ectedIndex = -1
cboArcirisUsers PrimarySite.Sel ectedIndex = -1
cboArcirisUsers Roles.Text = ""
cboArcirisUsers Roles.SelectedI ndex = -1
cboArcirisUsers Roles.SelectedI ndex = -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**********@p lanet.nl> wrote in message
news:OV******** ******@TK2MSFTN GP11.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.co m> schreef in bericht
news:GC******** ************@ka roo.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.Argumen tException' 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**********@p lanet.nl> wrote in message
news:uy******** ******@TK2MSFTN GP12.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 cboPasswordList sDepartment_Sel ectedIndexChang ed(ByVal sender
> As Object, ByVal e As System.EventArg s) Handles
> cboPasswordList sDepartment.Sel ectedIndexChang ed
> Me.BindingConte xt(dsPasswordLi st,

"PasswordList") .EndCurrentEdit ()
> If Me.BindingConte xt(dsPasswordLi st, "PasswordList") .Position <> -1
> And Not mlLoading Then
>
> dsPasswordList. PasswordList.Ro ws(Me.BindingCo ntext(dsPasswor dList,
> "PasswordList") .Position).Item ("DepartmentID" ) =
> Me.cboPasswordL istsDepartment. SelectedValue
> End If
> End Sub
>
> When I try and Add something to my Datatset the above errors saying
>
> An unhandled exception of type 'System.Argumen tException' occurred in > system.data.dll
> Additional information: Cannot set Column 'DepartmentID' to be null.
Please
> use DBNull instead.
>
> On this Line:
> dsPasswordList. PasswordList.Ro ws(Me.BindingCo ntext(dsPasswor dList,
> "PasswordList") .Position).Item ("DepartmentID" ) =
> Me.cboPasswordL istsDepartment. 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
2615
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 implementing this in C# ? I do not want to use variant (or similar types) because I want to retain a strnong types property. Will I have no choices but to add another property that would set/get the NULL value?
0
3580
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 Null. This method or property cannot be called on Null values. I figured out SqlDecimal.Null is used only with db Money fields. But when I changed SqlDecimal.Null to DBNull.Value I got the error: CS0173 Type of conditional expression can't be...
6
1996
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 an expression. Thanks
1
1912
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 URLSurgeS.Visible = "False" End If
1
3772
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 the following in the ItemDataBound event but it gave me an "invalid cast" error: DataRowView dataRowView = (DataRowView)e.Item.DataItem; for (int i=0; i<e.Item.Cells.Count - 1; i++) {
15
29280
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 containing the sort key value specified; otherwise a null value if the sort key value does not exist." By "null value", does it mean System.DBNull? (I thought only objects could evaluate to System.DBNull.) How can I test whether an integer variable...
9
3279
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 check for a NULL and if its NULL insert DBNull into the db? Currently I'm getting error message System.DBNull.System.IConvertible.ToBoolean() now i need to get this field and insert a NULL into the db is the values
2
2119
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 spaces 66 Else 67 strBD = objdr.Item("BD") 'All ok so leave as is 68 End If Here is the error I get:
10
2471
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 named UserComponents and creates an object named UserDetails. 3. The UserDB.cs file retrieves the actual data from the database. The code below has been condensed and only includes two fields from my datasource. I actually am also retrieving...
0
10232
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10059
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10008
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9873
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6682
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5454
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3974
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3578
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2822
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.