Set a Field to Null

  • Thread starter Thread starter Wayne Wengert
  • Start date Start date
W

Wayne Wengert

I am trying to set a field to Null using code such as:

dr("Contact2") = DBNull

But VB.NET won't accept that. I tried:

dr("Contact2") = Nothing

but that tells me to use DBNull



What is the correct syntax to accomplish this?



Wayne
 
dr("Contact2") = DBNull.Value

I am trying to set a field to Null using code such as:

dr("Contact2") = DBNull

But VB.NET won't accept that. I tried:

dr("Contact2") = Nothing

but that tells me to use DBNull



What is the correct syntax to accomplish this?



Wayne
 
Herfried & Shiva;

Thanks. Why do they do that? Null is always confusing enough to deal with!

Wayne
 
Hi,
Since DBNull is a class name, you use the Value property of it to get an
instance, which in turn used to assign for null values.

Herfried & Shiva;

Thanks. Why do they do that? Null is always confusing enough to deal with!

Wayne
 
Back
Top