Solved

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

Posted on 2002-03-13
7
866 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Why Bundles is not working on certain files - ASP MVC 3 59
Adding Row and Cell on a table 14 25
Weighted Randomizing 6 30
Load data upon clicking a button 8 34
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 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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

840 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