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