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="ADOD B" %>
<%
Dim Conn As ADODB.Connectio n
Dim adors As ADODB.Recordset
Dim sql As String
Dim copy As String
Conn = New ADODB.Connectio n
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("c opy_text").Valu e
if IsDBNull(adoRS. Fields("copy_te xt").Value) then
copy = "No Value"
else
copy = adoRS.Fields("c opy_text").Valu e
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 4 3450
That does seem kind of strange.
However, why are using ADO and not ADO.NET?
"Jim" <jr*********@ya hoo.com> wrote in message
news:ae******** *************** ***@posting.goo gle.com... 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="ADOD B" %> <% Dim Conn As ADODB.Connectio n Dim adors As ADODB.Recordset Dim sql As String Dim copy As String
Conn = New ADODB.Connectio n 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("c opy_text").Valu e if IsDBNull(adoRS. Fields("copy_te xt").Value) then copy = "No Value" else copy = adoRS.Fields("c opy_text").Valu e 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
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*********@ya hoo.com> wrote in message
news:ae******** *************** ***@posting.goo gle.com... 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="ADOD B" %> <% Dim Conn As ADODB.Connectio n Dim adors As ADODB.Recordset Dim sql As String Dim copy As String
Conn = New ADODB.Connectio n 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("c opy_text").Valu e if IsDBNull(adoRS. Fields("copy_te xt").Value) then copy = "No Value" else copy = adoRS.Fields("c opy_text").Valu e 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
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!
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*********@ya hoo.com> wrote in message
news:Oi******** ******@TK2MSFTN GP11.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! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 was loaded using a left join from two MS SQL database tables. The workphone element is null because there was no corresponding record from the right side of the join
The generated code for retrieving the value of 'Workphone' as a dataset property...
|
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
|
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 labels without checking first. Is
there a better method to write this than using a bunch of "If" statements?
Could it be a function? if so, how would I write it?
'Read the single record
While drLeadFeedback.Read()
If Not...
|
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) As String
Return IIf(IsDBNull(Value), "", Value)
End Function
|
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 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...
| |
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."
When I double click on it, I get the following dialog appear:
If I click 'No', for every object declared from the ADODB library, I get a
build error as follows: "Reference required to assembly 'ADODB' containing
the type 'ADODB.Connection'. Add...
|
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 being sent is Null using IsDBNull. I am using the following:
if (! IsDBNull(spCurrentHighLgt)) this.ltlCHLTitle.Text =
spCurrentHighLgt.toString();
However, I am getting the error that the name "IsDBNull" does not exist in
|
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 to String but
the data inside the column is a NULL.
Code prewritten by visual studio:
<System.Diagnostics.DebuggerNonUserCodeAttribute()_
|
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 modify my sql script because it is created dynamically.
Below I have the old method to check for DBNull and to deal with DBNull in
the recordset. This method of coding is used over 80 times as I have over 80
fields to check for DBNull, so a one...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |