473,387 Members | 1,597 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,387 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 19313
* "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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Colleyville Alan | last post by:
I have built a SQL statement that is trying to loop through the fields of a table that was built from a spreadsheet and hence is "short and fat". So rather than hard-coding, I have a loop from...
1
by: GGerard | last post by:
Hello I am working with Access 2000 I have two tables joined on a one to many relationship between two fields: Table1:FieldID (one) is joined to Table2:FieldMyID (many) Field Properties...
3
by: Orchid | last post by:
Hello All, Hope someone can help me on my required field problems. I have a form base on a table for users to input new Employees. There are 4 fields that cannot be Null when entering new...
10
by: MLH | last post by:
I have an A97 table with a Yes/No field named TowJob and a form bound to that table. The TowJob control on the form is bound to the same field. It is an option group with Yes and No bttns valued...
4
by: justin tyme | last post by:
Hello Experts! I would like to combine (which may not be the correct technical term) two text fields from the same table in a query. Specifically, text field A and text field B are both lists of...
4
by: subaruwrx88011 | last post by:
So I pressed tab-enter and posted an incomplete topic, sorry. I have imported information into a database using a file. It is tab delimited and for NULL fields I have NULL. example file.txt...
2
by: Brett | last post by:
My database has 2 tables: Table1 & Table2. If a field is not null on a record in table2, then the not null fields in table1 that correspond to the records in table1 needs to be updated to match the...
3
by: Finn Stampe Mikkelsen | last post by:
Hi I have defined a table in my database, with 2 date-fields. I have set a default value to DBNull. I have integrated a nullable datetimepicker control to my project and set the apropriate...
21
by: no1zson | last post by:
I do not even know how to correctly ask this question. I have an item field in the code I am about to post. Simple intger meant to be an item number for a cd. The user enters this number. Over the...
1
DebadattaMishra
by: DebadattaMishra | last post by:
Introduction In case of rich applications, you must have observed that a text field behaves like a dynamic combo box. When the user enters some characters in the text field, a popup will come up...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...

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.