473,403 Members | 2,323 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,403 software developers and data experts.

How do one test for nulls in VB?

Hello,

I am reading some records into a recordset when I got to assign a text
box the value of one of the fields I get an exception because the
recordset has a null value in it. How do you test for nulls in vb script?

Example:

txtModel.Text = SqlDataReader("Manufacturer") '
Manufacturer is null.

Regards,

Randy.
Nov 13 '07 #1
4 3517
If IsDBNull(SqlDataReader("Manufacturer")) Then
txtModel.Text = "N/A"
Else
txtModel.Text = SqlDataReader("Manufacturer")
End If

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Randy Galliano" <ra************@thegallianos.comwrote in message news:%2****************@TK2MSFTNGP02.phx.gbl...
Hello,

I am reading some records into a recordset when I got to assign a text box the value of one of the fields I get an
exception because the recordset has a null value in it. How do you test for nulls in vb script?

Example:

txtModel.Text = SqlDataReader("Manufacturer") ' Manufacturer is null.

Regards,

Randy.

Nov 13 '07 #2
"Randy Galliano" <ra************@thegallianos.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
Hello,

I am reading some records into a recordset when I got to assign a text box
the value of one of the fields I get an exception because the recordset
has a null value in it. How do you test for nulls in vb script?

Example:

txtModel.Text = SqlDataReader("Manufacturer") ' Manufacturer
is null.

Regards,

Randy.


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Nov 13 '07 #3
Randy Galliano wrote:
Hello,

I am reading some records into a recordset when I got to assign a text
box the value of one of the fields I get an exception because the
recordset has a null value in it. How do you test for nulls in vb script?

Example:

txtModel.Text = SqlDataReader("Manufacturer") ' Manufacturer
is null.

Regards,

Randy.

Let me clarify one more thing. I am using .net 2.0 with vb script.
According to the manual on MSDN isNull is a function I can use, but
Visual Studio is saying the function is not defined.

Regards,

Randy.
Nov 13 '07 #4
"Randy Galliano" <ra************@thegallianos.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
How do you test for nulls in vb script?
Assuming that you don't actually mean VBScript, you test for the field being
DbNull.Value...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Nov 13 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Dan Perlman | last post by:
From: "Dan Perlman" <dan@dpci.NOSPAM.us> Subject: ODBC creating nulls? Date: Friday, July 09, 2004 10:43 AM Hi, Below is my VB6 code that writes data from an Access 2000 table to a PG table....
2
by: Steve Walker | last post by:
Hi all. I've been tasked with "speeding up" a mid-sized production system. It is riddled with nulls... "IsNull" all over the procs, etc. Is it worth it to get rid of the nulls and not allow...
3
by: aaj | last post by:
Hi I am probably going to regret asking this because I'm sure you are going to tell me my design is bad 8-) ah well we all have to learn.... anyway I often use Nulls as a marker to see if...
6
by: mike | last post by:
I'm doing what I thought was a simple GROUP BY summary of fairly simple data and the my numbers aren't working out Some results are showing up <NULL> when I know the data is in the database ...
0
by: Rhino | last post by:
I am working with SQL Functions in DB2 for Windows/Linux/UNIX (V8.2.1) and am having a problem setting input parameters for SQL Functions to null in the Development Center. My simple function,...
1
by: PST | last post by:
Here's a problem I'm trying to deal with: I'm working on a Frontpage 2000 website for a boat handicapping system, built in Access 97. What I'm trying to accomplish is: The user enters a...
2
by: Dave | last post by:
I have an Access2K table in which several records have nulls in some fields. In code that iterates through this table the statement If Not IsNull() Then ... (or If IsNull() Then ...) is...
9
by: Steve Sargent | last post by:
Hi: I'm trying to debug the following code, and it keeps looping on the if statement: public static bool operator == (OnlineMemberNode first, OnlineMemberNode second) { if(first == null) {
6
by: Cliff72 | last post by:
I need to fill in the nulls in the batch field the value from the record immediately preceding the null one ie replace the nulls with the preceding value until I hit a record with a value in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.