HighTechTalks DotNet Forums  

DBNULL Error

VB.net microsoft.public.dotnet.languages.vb


Discuss DBNULL Error in the VB.net forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
MadCrazyNewbie
 
Posts: n/a

Default DBNULL Error - 05-05-2004 , 04:24 AM






Hey Group,

I keep getting this Error:

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

On the following line of code:

dsFax.Faxs.Rows(Me.BindingContext(dsFax, "Faxs").Position).Item("SitesID") =
Me.cboFaxsDepartment.SelectedValue

Anybody got any ideas or can point me in the right direction?

Many Thanks
MCN



Reply With Quote
  #2  
Old   
Lars Netzel
 
Posts: n/a

Default Re: DBNULL Error - 05-05-2004 , 04:46 AM






From the information you provided I would say that either you have no value
in the Me.cboFaxsDepartment.SelectedValue

check with:
MsgBox(Me.cboFaxsDepartment.SelectedValue

OR... something goes wrong when you save and you don't get a value for the
SitesID column.

Are you allowed to insert Null in "SitesID" column? in that case and if you
WANT TO insert a null value, then you better use DBNull

/Lars


"MadCrazyNewbie" <test (AT) nospam (DOT) com> skrev i meddelandet
newsamcnXICg9VMLAXdSa8jmw (AT) karoo (DOT) co.uk...
Quote:
Hey Group,

I keep getting this Error:

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

On the following line of code:

dsFax.Faxs.Rows(Me.BindingContext(dsFax, "Faxs").Position).Item("SitesID")
=
Me.cboFaxsDepartment.SelectedValue

Anybody got any ideas or can point me in the right direction?

Many Thanks
MCN





Reply With Quote
  #3  
Old   
Alex Papadimoulis
 
Posts: n/a

Default Re: DBNULL Error - 05-05-2004 , 09:29 AM



If Me.cboFaxsDepartment.SelectedValue Is Nothing Then
'you could also throw an exception or warning box instead of putting in DB
NULL
dsFax.Faxs.Rows(Me.BindingContext(dsFax, "Faxs").Position).Item("SitesID")
=
DbNull.Value
Else
dsFax.Faxs.Rows(Me.BindingContext(dsFax, "Faxs").Position).Item("SitesID")
=
Me.cboFaxsDepartment.SelectedValue
End If

"MadCrazyNewbie" <test (AT) nospam (DOT) com> wrote

Quote:
Hey Group,

I keep getting this Error:

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

On the following line of code:

dsFax.Faxs.Rows(Me.BindingContext(dsFax, "Faxs").Position).Item("SitesID")
=
Me.cboFaxsDepartment.SelectedValue

Anybody got any ideas or can point me in the right direction?

Many Thanks
MCN





Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.