Solved

**Invalid use of Null: 'CINT' **

Posted on 2002-03-13
7
863 Views
Last Modified: 2008-02-20
I'm geeting the following message:

Microsoft VBScript runtime error '800a005e'

Invalid use of Null: 'CINT'

on this line:

If CINT(rsSecondary.Fields("subjectid").Value) = CINT(rsMain.Fields("subjectid").Value) then
Response.Write (rsSecondary.Fields("MSGBID") & rsSecondary.Fields("subject"))

My first record set rsSecondary just does a select of 4 fields
My second record set does a select of 6 fields then I'm trying to display results where the subjectid fields are joined

I've never had this error before so I'm a little unsure where to start - I should say I get data displayed but only the first two records out of five that should get displayed in my test db then I get the error message.  Also, all my subjectids are less then 100 so it's not like I have to change to CLNG

Thanks  
0
Comment
Question by:dylanone
7 Comments
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 6862667
I am guessing that you are trying to take the CINT() of a null field and it is throwing back an error. Does your table allow nulls?

Fritz the Blank
0
 
LVL 46

Accepted Solution

by:
fritz_the_blank earned 80 total points
ID: 6862772
Try:

if not isNull(rsSecondary.Fields("subjectid").Val) and not isNull(rsMain.Fields("subjectid").Value) then
   If CINT(rsSecondary.Fields("subjectid").Value) = CINT(rsMain.Fields("subjectid").Value) then
Response.Write (rsSecondary.Fields("MSGBID") & rsSecondary.Fields("subject"))
   end if
end if
0
 
LVL 30

Expert Comment

by:third
ID: 6863079
better remove the CInt function. let them compare as strings. that wouldn't only work if you compare like '0001' = '1' but if you sure you will be comparing same type of data you can use this.

If rsSecondary.Fields("subjectid")= rsMain.Fields("subjectid") then
Response.Write (rsSecondary.Fields("MSGBID") & rsSecondary.Fields("subject"))

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Expert Comment

by:walbury
ID: 6863466
'third' is 3/4 of the way there; the best way to do it
is:
 dim sVal
 sVal=trim(cstr(rs("fldname")& ""))
 if sVal<>"" then
    'optional
    if isnumeric(sVal) then
        theValue=cint(sVal)'/clng(sVal)/cdbl etc.
    else
        theValue=0 'or whatever default value you desire
    end if
 else
    theValue=0 'or whatever default value you desire
 end if
'ideally you should wrap above in a function
From habit I (almost) never use cint etc because of exactly the reason you've found.
Background to code. By using cstr(x & "") you are forcing the value to a blank string so you don't have to worry about whether or not the original value was in fact a NULL or not.
HTH
w.
0
 
LVL 1

Expert Comment

by:loveneesh_bansal
ID: 6863536
Hi

the function cint is always looking for some data. But here in your case the value is null. So you cannot implement the cint function but you can get the same output with

x = rsSecondary.Fields("subjectid").Value
y = rsMain.Fields("subjectid").Value

if not isnull(x) then
x = cint(x)
end if

if not isnull(y) then
y = cint(y)
end if

If x = y then
Response.Write (rsSecondary.Fields("MSGBID") & rsSecondary.Fields("subject"))


this would solve your problem.

0
 
LVL 30

Expert Comment

by:third
ID: 6863596

loveneesh,

  got your tactic. ur using ur magic words again.... lol ;-)
0
 

Author Comment

by:dylanone
ID: 6865483
Thanks - this worked most efficiently for me
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now