Solved

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

Posted on 2002-03-13
7
862 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 1

Expert Comment

by:walbury
Comment Utility
'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
Comment Utility
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
Comment Utility

loveneesh,

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

Author Comment

by:dylanone
Comment Utility
Thanks - this worked most efficiently for me
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
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…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

763 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

9 Experts available now in Live!

Get 1:1 Help Now