Type Mismatch Error(numeric values)

Discussion in 'ASP General' started by Savas Ates, Oct 8, 2004.

  1. Savas Ates

    Savas Ates Guest

    i have 3 columns in sql server ..

    all of them are numeric value

    when a user enter my site i take the value of userid (numeric one) i assign
    it as session("userid ")

    after a query i take 2 value (both numeric again) from my table and write
    this code

    if towhom=session("userid") then towhom=fromwhom

    it gives an error .. how can i solve it

    Type Mismatch Error
     
    Savas Ates, Oct 8, 2004
    #1
    1. Advertising

  2. Have you tried casting your values to the same datatype?

    If CInt(towhom) = CInt(Session("UserID"))...

    Ray at work

    "Savas Ates" <> wrote in message
    news:...
    >i have 3 columns in sql server ..
    >
    > all of them are numeric value
    >
    > when a user enter my site i take the value of userid (numeric one) i
    > assign
    > it as session("userid ")
    >
    > after a query i take 2 value (both numeric again) from my table and write
    > this code
    >
    > if towhom=session("userid") then towhom=fromwhom
    >
    > it gives an error .. how can i solve it
    >
    > Type Mismatch Error
    >
    >
     
    Ray Costanzo [MVP], Oct 8, 2004
    #2
    1. Advertising

  3. Ray,

    Casting into String is the best option, since other cast functions give
    errors if the input is not numeric (e.g. empty)

    If CStr(towhom) = CStr(Session("UserID")) Then...

    --
    Manohar Kamath
    Editor, .netWire
    www.dotnetwire.com


    "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
    message news:%...
    > Have you tried casting your values to the same datatype?
    >
    > If CInt(towhom) = CInt(Session("UserID"))...
    >
    > Ray at work
    >
    > "Savas Ates" <> wrote in message
    > news:...
    > >i have 3 columns in sql server ..
    > >
    > > all of them are numeric value
    > >
    > > when a user enter my site i take the value of userid (numeric one) i
    > > assign
    > > it as session("userid ")
    > >
    > > after a query i take 2 value (both numeric again) from my table and

    write
    > > this code
    > >
    > > if towhom=session("userid") then towhom=fromwhom
    > >
    > > it gives an error .. how can i solve it
    > >
    > > Type Mismatch Error
    > >
    > >

    >
    >
     
    Manohar Kamath, Oct 8, 2004
    #3
  4. Good point.

    Ray at work

    "Manohar Kamath" <> wrote in message
    news:...
    > Ray,
    >
    > Casting into String is the best option, since other cast functions give
    > errors if the input is not numeric (e.g. empty)
    >
    > If CStr(towhom) = CStr(Session("UserID")) Then...
     
    Ray Costanzo [MVP], Oct 8, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. data type mismatch error

    , Aug 10, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    644
    Karl Seguin
    Aug 10, 2005
  2. type mismatch error

    , Aug 12, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    3,394
    Kevin Spencer
    Aug 12, 2005
  3. shan

    Type mismatch error

    shan, Nov 20, 2005, in forum: C Programming
    Replies:
    6
    Views:
    673
    Sandeep
    Nov 20, 2005
  4. darrel
    Replies:
    4
    Views:
    843
    darrel
    Jul 19, 2007
  5. programmingzeal
    Replies:
    0
    Views:
    1,152
    programmingzeal
    May 6, 2012
Loading...

Share This Page