May 5, 2005 at 3:19 pm
I have a stored procedure that pulls data from three different tables. I am using a LEFT JOIN because not all three tables have data for every user.
On my asp.net page I am using an if statement to determine if a panel is visible or not based on data from one of the tables. When the value is null I get the:
Operator is not valid for type 'DBNull' and type 'Integer'.
error message
Is there a way to test if the value is null and then convert it to a 0?
If CISCreated = 1 Then
ClientCIS = cmdSelect.ExecuteReader()
If the value is 1 I am adding a few values to the session.
May 5, 2005 at 8:49 pm
Have you tried using the IsNull function ?!
**ASCII stupid question, get a stupid ANSI !!!**
May 6, 2005 at 6:52 am
That would have to be in your Stored Procedure. And IsNull will rely on data actually being returned. Could you post what the output looks like for the data and if there is no row does Null actually return?
May 6, 2005 at 7:08 am
Here's an example...
SELECT ISNULL(CISCreated, 0) FROM Table will replace all Nulls with zeroes
**ASCII stupid question, get a stupid ANSI !!!**
May 6, 2005 at 8:46 am
I did end up doing the isnull in my stored procedure and it fixed the problem.
May 6, 2005 at 8:56 am
Great!
**ASCII stupid question, get a stupid ANSI !!!**
May 6, 2005 at 11:15 am
Wouldn't this ASP.NET code work as well? Though it may be better practice to let your server do more of the work, as you have done already.
If (Not IsNull(rsSomething("CISCreated")) Then ...
So long, and thanks for all the fish,
Russell Shilling, MCDBA, MCSA 2K3, MCSE 2K3
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply