1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Type mismatch error

Discussion in 'C#' started by rag84dec, Apr 20, 2008.

  1. #1
    Hi,
    I am assiging a the count(*) from a database query to a variable.But it is giving this error
    
    Error Type:
    Microsoft VBScript runtime (0x800A000D)
    Type mismatch
    
    Code (markup):
    the query is here
    
    sql="select count(*) from tablename where row=somevalue "
    set ObjRS=cn.execute(sql)
    dim variable
    variable=ObjRS(0)
    
    if variable <> 0 then 'Here i am getting an error mentioned 'above
    end if
    
    Code (markup):

     
    rag84dec, Apr 20, 2008 IP
  2. AstarothSolutions

    AstarothSolutions Peon

    Messages:
    2,680
    Likes Received:
    77
    Best Answers:
    0
    Trophy Points:
    0
    #2
    What data type is the column named "row" in the db? How is this value being populated in the query? What database are you using (access, MS SQL, MySQL etc)?
     
    AstarothSolutions, Apr 21, 2008 IP
  3. itcn

    itcn Well-Known Member

    Messages:
    795
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    118
    #3
    Try
    variable=CInt(ObjRS(0))
     
    itcn, Apr 21, 2008 IP
  4. drax2006

    drax2006 Well-Known Member

    Messages:
    233
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    118
    #4
    Beware the dreaded NULL value!

    NULL <> 0

    if in doubt

    if not isnull(variable) then
    if variable <> 0 then
    .
    .
    endif
    endif

    will prevent this
     
    drax2006, May 14, 2008 IP
  5. jawahar

    jawahar Active Member

    Messages:
    1,044
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    95
    #5
    Just put a

    cint(variable)<>0

    then it will work!! By default it will take as string!!! What a junk ;-)
     
    jawahar, May 25, 2008 IP