PC Review


Reply
Thread Tools Rate Thread

ADODB/IsDBNull Problem

 
 
Jim
Guest
Posts: n/a
 
      19th Jul 2004
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
 
Reply With Quote
 
 
 
 
Marina
Guest
Posts: n/a
 
      19th Jul 2004
That does seem kind of strange.

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

"Jim" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
Cablewizard
Guest
Posts: n/a
 
      19th Jul 2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
Jim Bailey
Guest
Posts: n/a
 
      19th Jul 2004
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!
 
Reply With Quote
 
Cablewizard
Guest
Posts: n/a
 
      20th Jul 2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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!



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
URGENT HELP ADODB VbScript vs ADODB.ConnectionClass() C# =?Utf-8?B?U2lsdmlhIEJydW5ldCBKb25lcw==?= Microsoft Dot NET Framework 9 13th Oct 2004 04:31 PM
Equivalent ADODB.Connector and ADODB.Recordset in VB.NET Marty Microsoft Dot NET 3 25th Sep 2004 10:36 PM
Equivalent ADODB.Connector and ADODB.Recordset in VB.NET Marty Microsoft VB .NET 3 25th Sep 2004 10:36 PM
Re: URGENT HELP ADODB VbScript vs ADODB.ConnectionClass() C# Cowboy \(Gregory A. Beamer\) [MVP] Microsoft ADO .NET 1 29th Jul 2004 02:11 PM
Re: URGENT HELP ADODB VbScript vs ADODB.ConnectionClass() C# Lucas Tam Microsoft ADO .NET 0 29th Jul 2004 04:34 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:06 AM.