473,473 Members | 2,272 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

ADODB/IsDBNull Problem

Jim
I am having a problem with the IsDBNull function. When it checks what
type of value is contained in the parameter that is passed to it, it
does not successfully determine that it has a DBNull value. If I
access the value of what I am going to pass to the IsDBNull function
before I call the IsDBNull function then it does successfully
determine that it has a DBNull value. Below is a page that I am using
to test. Note: that the value for the column copy_text is null in
this specific case.

<%@ Page %>
<%@ Import namespace="ADODB" %>
<%
Dim Conn As ADODB.Connection
Dim adors As ADODB.Recordset
Dim sql As String
Dim copy As String

Conn = New ADODB.Connection
Conn.Open("DSN=xxx;uid=xxx;pwd=xxx;")

adoRS = New ADODB.Recordset

sql = "select copy_text from printone_copy where ach_id = 43887"
adoRS.Open(sql, conn)

If Not adoRS.eof Then
'dim objtest as Object
'objtest = adoRS.Fields("copy_text").Value
if IsDBNull(adoRS.Fields("copy_text").Value) then
copy = "No Value"
else
copy = adoRS.Fields("copy_text").Value
end if
Else
copy = "No Value"
End If
adoRS.Close()

Response.Write(copy)
%>

If I uncomment the two lines before the IsDBNull function call then
the IsDBNull function correctly returns true, otherwise it returns
false. And when it returns false I get an error as it tries to put
DBNull into the string variable copy. Any help on this would be much
appreciated.

Jim
Jul 21 '05 #1
4 3429
That does seem kind of strange.

However, why are using ADO and not ADO.NET?

"Jim" <jr*********@yahoo.com> wrote in message
news:ae**************************@posting.google.c om...
I am having a problem with the IsDBNull function. When it checks what
type of value is contained in the parameter that is passed to it, it
does not successfully determine that it has a DBNull value. If I
access the value of what I am going to pass to the IsDBNull function
before I call the IsDBNull function then it does successfully
determine that it has a DBNull value. Below is a page that I am using
to test. Note: that the value for the column copy_text is null in
this specific case.

<%@ Page %>
<%@ Import namespace="ADODB" %>
<%
Dim Conn As ADODB.Connection
Dim adors As ADODB.Recordset
Dim sql As String
Dim copy As String

Conn = New ADODB.Connection
Conn.Open("DSN=xxx;uid=xxx;pwd=xxx;")

adoRS = New ADODB.Recordset

sql = "select copy_text from printone_copy where ach_id = 43887"
adoRS.Open(sql, conn)

If Not adoRS.eof Then
'dim objtest as Object
'objtest = adoRS.Fields("copy_text").Value
if IsDBNull(adoRS.Fields("copy_text").Value) then
copy = "No Value"
else
copy = adoRS.Fields("copy_text").Value
end if
Else
copy = "No Value"
End If
adoRS.Close()

Response.Write(copy)
%>

If I uncomment the two lines before the IsDBNull function call then
the IsDBNull function correctly returns true, otherwise it returns
false. And when it returns false I get an error as it tries to put
DBNull into the string variable copy. Any help on this would be much
appreciated.

Jim

Jul 21 '05 #2
I have not seen it behave like this before.
What type of database are you connecting to?
You may need to explicitly change either the connection or recordset parameters.
But at this point I don't know what you would need to change, cause as best I
can tell it should be working.

Gerald

"Jim" <jr*********@yahoo.com> wrote in message
news:ae**************************@posting.google.c om...
I am having a problem with the IsDBNull function. When it checks what
type of value is contained in the parameter that is passed to it, it
does not successfully determine that it has a DBNull value. If I
access the value of what I am going to pass to the IsDBNull function
before I call the IsDBNull function then it does successfully
determine that it has a DBNull value. Below is a page that I am using
to test. Note: that the value for the column copy_text is null in
this specific case.

<%@ Page %>
<%@ Import namespace="ADODB" %>
<%
Dim Conn As ADODB.Connection
Dim adors As ADODB.Recordset
Dim sql As String
Dim copy As String

Conn = New ADODB.Connection
Conn.Open("DSN=xxx;uid=xxx;pwd=xxx;")

adoRS = New ADODB.Recordset

sql = "select copy_text from printone_copy where ach_id = 43887"
adoRS.Open(sql, conn)

If Not adoRS.eof Then
'dim objtest as Object
'objtest = adoRS.Fields("copy_text").Value
if IsDBNull(adoRS.Fields("copy_text").Value) then
copy = "No Value"
else
copy = adoRS.Fields("copy_text").Value
end if
Else
copy = "No Value"
End If
adoRS.Close()

Response.Write(copy)
%>

If I uncomment the two lines before the IsDBNull function call then
the IsDBNull function correctly returns true, otherwise it returns
false. And when it returns false I get an error as it tries to put
DBNull into the string variable copy. Any help on this would be much
appreciated.

Jim

Jul 21 '05 #3
I am connecting to a MS SqlServer 2000 DB. And I am using ADODB because
we are doing a port of an asp application to asp.net and want to do a
minimal amount of code change to start with. I have not investigated
changing connection or recordset parameters yet. I was hoping that
someone else had run into this problem before me. I will see what
progress I can make with changing the parameters.

Jim

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 21 '05 #4
ah, hmm. well, ADO works best with MS SQL 2K, so I am stumped.
Maybe it has something to do with ASP?
I still use ADO a lot instead of ADO.Net for similar reasons.
But I don't do much in ASP and I have yet to encounter that particular problem
with normal apps. wish I could help.

Gerald

"Jim Bailey" <jr*********@yahoo.com> wrote in message
news:Oi**************@TK2MSFTNGP11.phx.gbl...
I am connecting to a MS SqlServer 2000 DB. And I am using ADODB because
we are doing a port of an asp application to asp.net and want to do a
minimal amount of code change to start with. I have not investigated
changing connection or recordset parameters yet. I was hoping that
someone else had run into this problem before me. I will see what
progress I can make with changing the parameters.

Jim

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 21 '05 #5

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

Similar topics

19
by: jim | last post by:
This line of code returns error 13, cast from 'DBNull' to type 'String' is not valid If IsDBNull(Clinics.Clinics.Item(A).Workphone) The <other code End I Clinics.Clinics is a dataset that...
5
by: luna | last post by:
how to i use isdbnull on two tables ? im pulling out the data with a stored procedure like this :- CREATE PROCEDURE search @search varchar(8) AS
3
by: Paul D. Fox | last post by:
I have this code snippet below where I'm loading all the labels based upon the retrieved record from the DataReader. Unfortunatley, some of the values are null, so I can't explicitly set the...
4
by: Edwinah63 | last post by:
Hi guys, i have a collection containing the values and metadata about a current record. i build it by looping through the recordset as follows: Public Function NoNull(ByVal Value As Object)...
4
by: Jim | last post by:
I am having a problem with the IsDBNull function. When it checks what type of value is contained in the parameter that is passed to it, it does not successfully determine that it has a DBNull...
6
by: Wonder | last post by:
We have a VB.NET project with a reference to ADO 2.5 When I open it on my machine, I get the following build error: "The referenced component 'ADODB' has an updated custom wrapper available." ...
4
by: sck10 | last post by:
Hello (converting from vb to c#), Is there a way to test the value of null of a particular field of a dataset from SQL Server? I am going through a dataset and trying to determine if the value...
4
by: Brad Isaacs | last post by:
I am using ASP.NET 2.0 codebehind Visual Basic, Visual Studio 2005 Working with DataSet creating a Data Access Layer via VS 2005. My error is when the code that is prewritten by VS 2005 Casts...
2
by: =?Utf-8?B?TWlrZSBPS0M=?= | last post by:
VB 2005 All developers face this issue; so I'm sure Microsoft was a solution for it. What is the built in method to check DBNull in a recordset field? NOT a typed dataset. I don't want to...
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...
1
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.