If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > CHECK BOX insert problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-07-03, 08:03
donaldt donaldt is offline
Registered User
 
Join Date: Jan 2002
Location: Nottingham - UK
Posts: 113
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
Reply With Quote
  #2 (permalink)  
Old 08-07-03, 12:17
unatratnag unatratnag is offline
Registered User
 
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...
Reply With Quote
  #3 (permalink)  
Old 08-11-03, 03:01
Memnoch1207 Memnoch1207 is offline
Registered User
 
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.
Reply With Quote
  #4 (permalink)  
Old 08-11-03, 10:31
donaldt donaldt is offline
Registered User
 
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 !
Reply With Quote
  #5 (permalink)  
Old 08-12-03, 17:52
Memnoch1207 Memnoch1207 is offline
Registered User
 
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 & "')
Reply With Quote
  #6 (permalink)  
Old 08-14-03, 03:45
donaldt donaldt is offline
Registered User
 
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 & "')
Reply With Quote
  #7 (permalink)  
Old 08-14-03, 06:35
unatratnag unatratnag is offline
Registered User
 
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'
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On