Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Request Object Error 'ASP 0102:80004005' 1

Status
Not open for further replies.

ppedersen1

Technical User
Oct 14, 2002
43
US
Hello,
I am getting an error which doesn't make sense to me. Firstly, I am trying to get input data and submit it to an Access Database. It works fine until I include a column using a checkbox then it acts weird. The error code I get is:

Request object error 'ASP 0102: 80004005'
Expecting string input
<doc path>, line 22
The function expects a string as input.

I am using the input type=&quot;checkbox&quot; name&quot;Update&quot;. Then when it goes to the Request.Form portion it doesn't like it. However, it worked with the input type=&quot;text items. Any clues? It has got to be something simply. However, I haven't been able to locate it.
Thanks.
 
You should have a function somewhere waiting a string as parameter.
Before, you &quot;fed&quot; it with a textbox.value which returns a string -> All is ok
Since change, you &quot;fed&quot; it with a checkBox.value which is boolean.
May be your error comes from here. Water is not bad as long as it stays out human body ;-)
 
There are two files which I am using. I have included them here. I changed my columns to relate to cars.

This one is called carsform.asp

<html>
<head>
<title>Cars Database Update Form</title>
</head>
<body>
<!-- Begin code -->
<form name=&quot;form&quot; method=&quot;post&quot; action=&quot;addcars.asp&quot;>
CarType: <input type=&quot;text&quot; name=&quot;CarType&quot;><br>
Color: <input type=&quot;text&quot; name=&quot;Color&quot; maxlength=&quot;255&quot;><br>
Convertible: <input type=&quot;checkbox&quot; name=&quot;Convertible&quot; value=&quot;&quot;><br>
<input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Submit&quot;>
</form>
</body>
</html>

Here is the other file, addtocars.asp

<%
Dim adoCon
Dim rsAddCARS
Dim strSQL
Set adoCon = Server.CreateObject(&quot;ADODB.Connection&quot;)
adoCon.Open &quot;DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=&quot;& Server.MapPath(&quot;cars.mdb&quot;)
Set rsAddCARS = Server.CreateObject(&quot;ADODB.Recordset&quot;)
strSQL = &quot;SELECT cars.* FROM cars;&quot;
rsAddCARS.CursorType = 2
rsAddCARS.LockType = 3
rsAddCARS.Open strSQL, adoCon
rsAddCARS.AddNew
rsAddCARS.Fields(&quot;CarType&quot;) = Request.Form(&quot;CarType&quot;)
rsAddCARS.Fields(&quot;Color&quot;) = Request.Form(&quot;Color&quot;)
rsAddCARS.Fields(&quot;Convertible&quot;) = Request.Form(&quot;Convertible&quot;)
rsAddCARS.Update
rsAddCARS.Close
Set rsAddCARS = Nothing
Set adoCon = Nothing
Response.Redirect &quot;cars.asp&quot;
%>


These ASP pages work until it gets to the checkbox item and then it doesn't like it. Do you see anything wrong? Do you have another way it will work. I tried to keep my pages simple. Thanks. I would really like to get this to work. I got some cool pages which display the data but I really need to make it updateable, then I will do the deleteable and editable features. Thanks.
 
What is the data type of the &quot;Convertible&quot; column in &quot;cars&quot; table in your database ? Water is not bad as long as it stays out human body ;-)
 
It is a checkbox. When you go to design in Access it is a &quot;Yes/No&quot; field.
 
Hi,

Checkboxes behave differently than text boxes. If not checked, nothing comes back. You have to check for both conditions.

What I use is this:

If Request.Form(&quot;DTH&quot;) = &quot;CHK&quot; Then strDTH = &quot;DTH&quot;
If Len(Request.Form(&quot;DTH&quot;)) = 0 Then strDTH = &quot;&quot;

Where DTH is the control name and &quot;CHK&quot; is the value.
There may be other ways to handle it but this seems to work for me.
If your data field is a boolean checkbox, values should be set for -1 or 0.

Hope this helps.

 
Thanks. I believe I get what you are saying...but I'm still a little fuzzy. From the coding that I included above, where should I put the code you propose?
 
Try the following :
Code:
<%
Dim adoCon
Dim rsAddCARS
Dim strSQL
Set adoCon = Server.CreateObject(&quot;ADODB.Connection&quot;)
adoCon.Open &quot;DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=&quot;& Server.MapPath(&quot;cars.mdb&quot;)
Set rsAddCARS = Server.CreateObject(&quot;ADODB.Recordset&quot;)
strSQL = &quot;SELECT cars.* FROM cars;&quot;
rsAddCARS.CursorType = 2
rsAddCARS.LockType = 3
rsAddCARS.Open strSQL, adoCon
rsAddCARS.AddNew
rsAddCARS.Fields(&quot;CarType&quot;) = Request.Form(&quot;CarType&quot;)
rsAddCARS.Fields(&quot;Color&quot;) = Request.Form(&quot;Color&quot;)
chkValue = Request.Form(&quot;Convertible&quot;)
if (chkValue=true or chkValue=&quot;true&quot;) Then
  rsAddCARS.Fields(&quot;Convertible&quot;) = &quot;Yes&quot; 
else
  rsAddCARS.Fields(&quot;Convertible&quot;) = &quot;No&quot;
End if 
rsAddCARS.Update
rsAddCARS.Close
Set rsAddCARS = Nothing
Set adoCon = Nothing
Response.Redirect &quot;cars.asp&quot;
%>
[code]
If that doesn't work, try different values for the test and the field. Water is not bad as long as it stays out human body ;-)
 
Holy Jesus! I spent quite a bit of time on this one. Targol thanks for the code. The values however didn't work. I spent a while trying quite a few &quot;reasonably accurate&quot; values until finally the following worked:

chkValue = Request.Form(&quot;Convertible&quot;)
If chkValue = &quot;0&quot; Then
rsAddCARS.Fields(&quot;Convertible&quot;) = &quot;true&quot;
else
rsAddCARS.Fields(&quot;Convertible&quot;) = &quot;false&quot;
Enf If

I also put &quot;Dim chkValue&quot; at the top.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top