Type mismatch error - help please

Discussion in 'ASP General' started by zenfor, Nov 29, 2006.

  1. zenfor

    zenfor Guest

    Hi, appreciate any help with this, I can't seem to get past this error.
    The Price field is a Number Data Type.

    This is part of some code that is adding records to a database. The 3
    lines of x_author (text data type) works fine. The error is coming at
    the "rs("price") = tmpFld" line. I assume I don't have it defined
    correctly but not quite sure how to fix it. Thanks!
    ===========================


    tmpFld = Trim(x_author)
    If trim(tmpFld) & "x" = "x" Then tmpFld = Null
    rs("author") = tmpFld

    ------->ERROR HERE!!
    tmpFld = Trim(x_price)
    If trim(tmpFld) & "x" = "x" Then tmpFld = Null
    rs("price") = tmpFld
     
    zenfor, Nov 29, 2006
    #1
    1. Advertising

  2. Hi,

    Propably the problem is that the tmpFld variable is set to Null
    i dont think a number type fiedl in the database can accept null value.

    Try this, just to make sure:
    replace the Null with a 0 and see if still gets out the same error. If
    it does then replace this line:
    rs("price") = tmpFld
    with:
    rs("price") = int(tmpFld)

    Tell me what goes on with u.

    Best Regards
    Firas S Assaad

    zenfor wrote:
    > Hi, appreciate any help with this, I can't seem to get past this error.
    > The Price field is a Number Data Type.
    >
    > This is part of some code that is adding records to a database. The 3
    > lines of x_author (text data type) works fine. The error is coming at
    > the "rs("price") = tmpFld" line. I assume I don't have it defined
    > correctly but not quite sure how to fix it. Thanks!
    > ===========================
    >
    >
    > tmpFld = Trim(x_author)
    > If trim(tmpFld) & "x" = "x" Then tmpFld = Null
    > rs("author") = tmpFld
    >
    > ------->ERROR HERE!!
    > tmpFld = Trim(x_price)
    > If trim(tmpFld) & "x" = "x" Then tmpFld = Null
    > rs("price") = tmpFld
     
    Firas S Assaad, Nov 30, 2006
    #2
    1. Advertising

  3. zenfor

    Mike Brind Guest

    "zenfor" <> wrote in message
    news:...
    > Hi, appreciate any help with this, I can't seem to get past this error.
    > The Price field is a Number Data Type.
    >
    > This is part of some code that is adding records to a database. The 3
    > lines of x_author (text data type) works fine. The error is coming at
    > the "rs("price") = tmpFld" line. I assume I don't have it defined
    > correctly but not quite sure how to fix it. Thanks!
    > ===========================
    >
    >
    > tmpFld = Trim(x_author)
    > If trim(tmpFld) & "x" = "x" Then tmpFld = Null
    > rs("author") = tmpFld
    >
    > ------->ERROR HERE!!
    > tmpFld = Trim(x_price)
    > If trim(tmpFld) & "x" = "x" Then tmpFld = Null
    > rs("price") = tmpFld
    >


    Could you be a bit more explicit about which liine throws an error, and what
    the error is? You say that the line rs("price") = tmpFld causes the error
    in your preamble, but the code suggests the error is being thrown at tmpFld
    = Trim(x_price).

    Where does x_price get its value from? Also, why are you creating a
    recordset to perform an Insert? And what type and version of database are
    you using?

    --
    Mike Brind
     
    Mike Brind, Nov 30, 2006
    #3
    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:
    640
    Karl Seguin
    Aug 10, 2005
  2. type mismatch error

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

    Type mismatch error

    shan, Nov 20, 2005, in forum: C Programming
    Replies:
    6
    Views:
    662
    Sandeep
    Nov 20, 2005
  4. Murrgon
    Replies:
    1
    Views:
    392
    Thomas Jollans
    Jun 10, 2010
  5. programmingzeal
    Replies:
    0
    Views:
    1,135
    programmingzeal
    May 6, 2012
Loading...

Share This Page