473,394 Members | 1,787 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,394 software developers and data experts.

Checking for DBNull

Hi

I am using a oledb reader to read from a table. The problem is that system
generates an exception when MyReader.GetValue(2) returns a value of type
system.dbnull. The system does not allow me to test this expression for
system.dbnull as below;

If objResultClient.GetValue(2) Is System.DBNull Then

How can I check objResultClient.GetValue(2) = System.DBNull for dbnull
value? I have tried objResultClient.GetValue(2) Is Nothing as well but that
does not catch system.dbnull values either.

Thanks

Regards
Jan 10 '08 #1
3 2741
If objResultClient.IsDBNull(2) Then
// Do your stuff here
End If

/claes

"John" <Jo**@nospam.infovis.co.ukwrote in message
news:eo**************@TK2MSFTNGP06.phx.gbl...
Hi

I am using a oledb reader to read from a table. The problem is that system
generates an exception when MyReader.GetValue(2) returns a value of type
system.dbnull. The system does not allow me to test this expression for
system.dbnull as below;

If objResultClient.GetValue(2) Is System.DBNull Then

How can I check objResultClient.GetValue(2) = System.DBNull for dbnull
value? I have tried objResultClient.GetValue(2) Is Nothing as well but
that does not catch system.dbnull values either.

Thanks

Regards

Jan 10 '08 #2
John wrote:
How can I check objResultClient.GetValue(2) = System.DBNull for dbnull
value?
If objResultClient.GetValue(2) Is System.DBNull.Value Then
. . .

HTH,
Phill W.
Jan 10 '08 #3
"John" <Jo**@nospam.infovis.co.ukschrieb:
I am using a oledb reader to read from a table. The problem is that system
generates an exception when MyReader.GetValue(2) returns a value of type
system.dbnull. The system does not allow me to test this expression for
system.dbnull as below;

If objResultClient.GetValue(2) Is System.DBNull Then
'If ... Is DBNull.Value Then...' or 'If IsDBNull(...) Then...'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Jan 11 '08 #4

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

Similar topics

3
by: JackO | last post by:
I have a text box on a form “txtExamDate” that I know contains nothing. I am trying to test code that will determine the text box is nothing. I am getting the error because there is no value...
1
by: excelleinc.com | last post by:
Hi, I'm trying to check if field contains NULL value in MSSQl 2000 database but keep receiving error. asp.net code: If Trim(HLSQLDSet.Tables("mfglinks").Rows(15).Item(0)) Is Null Then...
2
by: Kurt Schroeder | last post by:
I have a query result set that returns some fields with null length what is the easiest way to chek for this. This is what i'm trying but it generated a runtime error: If...
2
by: Andy G | last post by:
How can I check this for null? dsPrsn.Tables(0).Rows(0)("WORK_STATE") I tried If IsDbNull(dsPrsn.Tables(0).Rows(0)("WORK_STATE")) Then it seems not too work. I am attempting to check this field...
1
by: G Dean Blake | last post by:
I read in an earlier post that this would work: If Not myrow.DeletedByUser Is DBNull.Value Then But it gets a diagnostic if DeletedByUser is a boolean. How can I check to see if a boolean is...
3
by: rcolby | last post by:
Hi all, I'm experiecing a problem with dates being returned from SQL 2000 Database. I retrieve the last updated field (Date) from a sql 2000 and then compare the returned date with another...
7
by: Vayse | last post by:
i want to check if the following field is null. Dim rsAssets As New ADODB.Recordset rsAssets.Fields("SubIcon").Value) IsNull is no longer supported, so what should I use? Thanks
5
by: Leon Mayne | last post by:
We currently have lots of checks in our businesslayer object's Load() functions that look like: If drCourse("txtTTMCnotes").Equals(DBNull.Value) Then Me._txtTTMCnotes = "" Else...
5
by: bob | last post by:
Hi, i want to check whether the textbox of the detailsview is not left empty, in insert mode. I did this: Protected Sub DetailsView1_ItemInserting(ByVal sender As Object, ByVal e As...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.