?
Solved

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

Posted on 2002-03-13
7
Medium Priority
?
875 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 320 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

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…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

752 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