473,395 Members | 1,488 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,395 software developers and data experts.

pass DBNull.Value as paramter of type object

I would like to pass a DataRow column value to a method that accepts an
object parameter :

MyMethod( object value ) {}
However, a problem occurs if the column value is DBNull.Value

MyMethod( DataRow["MyCol"] );
A null reference exception is thrown in this case.

What is the reason that a DBNull.Value can't be passed as a parameter of
type object ?
Sep 30 '08 #1
1 2921
MyMethod( DataRow["MyCol"] );

It can.
Are you sure that DataRow is non null and that the column is spelt
correctly? Other than that, the bug is in some of the code not shown.

Marc
Sep 30 '08 #2

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

Similar topics

3
by: Brian | last post by:
I am trying to pass a null value into a stored procedure so that it can save the data. I am using Microsoft's SQLHelper dll to do this. My example code is below. How do I pass in a null value...
5
by: DraguVaso | last post by:
Hi, Something I don't understand about a Typed DataSet: When a value in the DataSet is DBNull, it throws this error: "Cannot get value because it is DBNull". But aren't Typed DataSets...
4
by: Brian Brane | last post by:
I have properties that wrap DataRow columns as in: public int aNumber { get{ return m_DataRow; } set{ m_DataRow = value; } } If the column happens to contain DBNull, I get a cast exception...
9
by: Alan Silver | last post by:
Hello, I'm a bit surprised at the amount of boilerplate code required to do standard data access in .NET and was looking for a way to improve matters. In Classic ASP, I used to have a common...
6
by: tshad | last post by:
I have a value coming from my Object (or it could also be from a SqlDbReader) where I need to test for DBNull and 0. I tried to do it in one call: if (not (newPosition.ReportsTo is...
2
by: Julian | last post by:
I have the following code: Dim strQuery As String = "SELECT tblData.CoPayFundGrant, tblData.M_DSS_SSA_Benefits, tblData.O_DSS_SSA_Benefits, " & _ "tblData.Ref_MPS, tblData.Ref_LA,...
6
by: Charlie Brown | last post by:
When checking for NULL values from a database, normally I would use If Not row("NetSales") Is DBNull.Value Then NetSales = row("NetSales") End If However, if I use a typed dataset then I...
6
by: scott ocamb | last post by:
Hello, I have a function that expects the following parms. How can I handle null values. For example, if FirstName comes through as null, how can i propogate that null value to the stored...
5
by: Leon Mayne | last post by:
We currently have lots of checks in our businesslayer object's Load() functions that look like: If drCourse("txtTTMCnotes").Equals(DBNull.Value) Then Me._txtTTMCnotes = "" Else...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
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...

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.