Results 1 to 7 of 7
  1. #1
    Join Date
    Jan 2002
    Location
    Nottingham - UK
    Posts
    113

    Unanswered: CHECK BOX insert problem

    Hi - I have a check on my form that I am getting the follow error upon submit:

    Provider error '80020005'

    Type mismatch.

    In my code as below:

    objRS("married") = Request.Form("married")

    Can anyone tell me whats wrong ?

    Thanks

  2. #2
    Join Date
    Jul 2003
    Location
    Ohio/Chicago
    Posts
    75
    I assume it's vbscript, it may be a typecast problem due to all variables are var by default and Record Sets are not, do a type cast and see if that works, example
    Code:
    objRS("married") = Cstr(request.form("married"))
    see if that works at all...

  3. #3
    Join Date
    Jan 2003
    Location
    Midwest
    Posts
    138
    checkboxes return either 1 (checked) or 0 (unchecked)...depending on what your doing with it (like inserting the info into a database) you would have to verify that the "married" field is an integer data type, or convert the 1 or 0 to a string as suggested above.

  4. #4
    Join Date
    Jan 2002
    Location
    Nottingham - UK
    Posts
    113
    Hi - still have some problems with this.....

    In my code I am using: objRS("married") = Cstr(request.form("married"))

    And in my db which is an access 2000 I have tried setting the field value to either Yes/No or a OLE field

    Both give me the error below:

    Provider error '80020005'

    Type mismatch.

    /wills_questionnaire.asp, line 40

    Any idea's appreciated !

  5. #5
    Join Date
    Jan 2003
    Location
    Midwest
    Posts
    138
    you'll have to manipulate the data.
    If the checkbox returns 1 (its checked) you can't insert a 1 into a Yes/No field so you'll have to change it to a yes or no according to what the checkbox is returning
    Code:
    If(Request.Form("married") = 1) then
       married = "Yes"
    Else
       married = "No"
    End If
    
    INSERT INTO TABLE VALUES('" & married & "')

  6. #6
    Join Date
    Jan 2002
    Location
    Nottingham - UK
    Posts
    113
    Another question... complete newbie

    I have about 20 check boxes on my form, dont know how to incorporate all the else / end ifs......

    Can you help - many thanks..

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    objRS("married") = Cstr(request.form("married"))
    objRS("children") = Cstr(request.form("children"))
    objRS("pets") = Cstr(request.form("pets"))

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    If(Request.Form("married") = 1) then
    married = "Yes"
    Else
    married = "No"
    End If

    INSERT INTO TABLE VALUES('" & married & "')

  7. #7
    Join Date
    Jul 2003
    Location
    Ohio/Chicago
    Posts
    75
    do all the ifs first and then do one insert at the end.
    Code:
    if request.form("object") = "1" then
            varname = "yes"
    else
            varname = "no"
    end if
    then just do that for each checkbox.

    at the end, do the insert
    Code:
    UPDATE TABLE name
    SET columnname = ' varname',
    columnname2 = 'varname2',
    etc
    WHERE uniqueID = 'whatever your identifier or however else your identifing the record'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •