Cerebrus
unread,Feb 1, 2009, 3:56:51 PM2/1/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
Under normal conditions, a simple test of Object.Equals
(System.DBNull.Value) should be sufficient. But in this case you are
using typed datasets within which each object is strongly typed. It is
my deduction that Objects such as integers might not be nullable and
therefore cannot be compared to DBNull, resulting in the InvalidCast.
It may be helpful to take a hint from Jayg28's suggestion and use
Convert.ToString() on the object first.
Another method may be :
---
// o is an Object returned by your Database
if (o != null && o != DBNull.Value)
{
// o can be accessed.
}
---