469,302 Members | 2,074 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,302 developers. It's quick & easy.

Set a Field to Null

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
Nov 21 '05 #1
6 18969
* "Wayne Wengert" <wa***************@wengert.com> scripsit:
I am trying to set a field to Null using code such as:

dr("Contact2") = DBNull


'DBNull.Value'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #2
dr("Contact2") = DBNull.Value

"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:eU**************@TK2MSFTNGP09.phx.gbl...
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

Nov 21 '05 #3
Herfried & Shiva;

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

Wayne

"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:eU**************@TK2MSFTNGP09.phx.gbl...
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

Nov 21 '05 #4
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.

"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:eE**************@TK2MSFTNGP11.phx.gbl...
Herfried & Shiva;

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

Wayne

"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:eU**************@TK2MSFTNGP09.phx.gbl...
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


Nov 21 '05 #5

"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:eE**************@TK2MSFTNGP11.phx.gbl...
Herfried & Shiva;

Thanks. Why do they do that?


It's the Object Oriented way. You will be assimilated.
Nov 21 '05 #6
I surrender - I am just slow!!!!

"Jeff Johnson [MVP: VB]" <i.***@enough.spam> wrote in message
news:ee****************@tk2msftngp13.phx.gbl...

"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:eE**************@TK2MSFTNGP11.phx.gbl...
Herfried & Shiva;

Thanks. Why do they do that?


It's the Object Oriented way. You will be assimilated.

Nov 21 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Colleyville Alan | last post: by
3 posts views Thread by Orchid | last post: by
4 posts views Thread by subaruwrx88011 | last post: by
3 posts views Thread by Finn Stampe Mikkelsen | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.