Solved

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

Posted on 2002-03-13
7
869 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

695 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