471,895 Members | 2,330 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,895 software developers and data experts.

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 19197
* "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
reply views Thread by YellowAndGreen | last post: by
reply views Thread by zermasroor | last post: by

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.