472,142 Members | 1,171 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,142 software developers and data experts.

Microsoft VBScript runtime (0x800A01A8) Object Required: "

66
hi everyone!

any advice given will be MUCH appreciated, i have spent about 10 hours on this bit of script... a rating system. I am having realt trouble overcoming this problem at runtime

Microsoft VBScript runtime (0x800A01A8)
Object required: ''
/ddwassignment2/full_catalogue2.asp, line 180

please find the complete code listing below, i have highlighted line 180... if you spot any other errors please let me know! The function begins on line: 62

Expand|Select|Wrap|Line Numbers
  1. <%@LANGUAGE="VBSCRIPT"%>
  2. <!--#include file="Connections/music_world.asp" -->
  3.  
  4.  
  5.  
  6. <%
  7. Dim Recordset1
  8. Dim Recordset1_cmd
  9. Dim Recordset1_numRows
  10.  
  11. Set Recordset1_cmd = Server.CreateObject ("ADODB.Command")
  12. Recordset1_cmd.ActiveConnection = MM_music_world_STRING
  13. Recordset1_cmd.CommandText = "SELECT * FROM tbl_cds" 
  14. Recordset1_cmd.Prepared = true
  15.  
  16. Set Recordset1 = Recordset1_cmd.Execute
  17. Recordset1_numRows = 0
  18. %>
  19.  
  20. <%
  21. dim rs1
  22. dim avgRating
  23. dim avgWhole
  24. dim decPart
  25. dim decCalc
  26. dim finalRating
  27. dim altText
  28. %>
  29.  
  30. <%
  31. Dim Repeat1__numRows
  32. Dim Repeat1__index
  33.  
  34. Repeat1__numRows = 5
  35. Repeat1__index = 0
  36. Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
  37. %>
  38. <html>
  39. <head>
  40. <title>Untitled Document</title>
  41. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  42. <style type="text/css">
  43. <!--
  44. .style1 {
  45.     color: #FF6633;
  46.     font-weight: bold;
  47. }
  48. -->
  49. </style>
  50.  
  51. </head>
  52. <body>
  53.  
  54. <p align="left" class="style1">Full CD catalogue</p>
  55. <hr><hr>
  56. <p align="left" class="style1">&nbsp;</p>
  57. <div align="left">
  58.  
  59.  
  60. <%
  61.  
  62. function ShowRating(cdid)
  63.  
  64. const MIN_RATINGS_BEFORE_SHOW = 1
  65.  
  66. dim Recordset2
  67. dim avgRating
  68. dim avgWhole
  69. dim decPart
  70. dim decCalc
  71. dim finalRating
  72. dim altText 
  73. dim conn
  74.  
  75. set conn = Server.CreateObject("ADODB.Connection") 
  76. set Recordset2 = Server.CreateObject("ADODB.Recordset")
  77.  
  78. conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\inetpub\wwwroot\ddwassignment2\music_world.mdb"
  79.  
  80. Recordset2 = "SELECT SUM(rating), COUNT(*) FROM ratings WHERE cdid = " & cdid
  81.  
  82.  
  83.  
  84. 'This CD has ratings, let's display the average
  85. avgRating = Recordset2.Fields(0).Value / Recordset2.Fields(1).Value 
  86.  
  87. if Instr(1, CStr(avgRating), ".") > 0 then
  88.  
  89. 'The average rating is a decimal, we need to either
  90. 'round the value up/down
  91.  
  92. avgWhole = Left(CStr(avgRating), Instr(1, CStr(avgRating), ".")-1)
  93. decPart = Mid(CStr(avgRating), Instr(1, CStr(avgRating), ".")+1, 2)
  94.  
  95. if decPart <> "" then
  96. 'Work out whether or not we have to round this
  97. 'rating up or down
  98.  
  99. if CInt(decPart) >= 5 then
  100. decCalc = .5
  101. else
  102. decCalc = 0
  103. end if
  104.  
  105. finalRating = CInt(avgWhole) + CCur(decCalc)
  106.  
  107. else
  108. finalRating = avgRating
  109. end if
  110. else
  111. finalRating = avgRating
  112. end if 
  113.  
  114. 'Setup the alt text for the images
  115. altText = "Average visitor rating of " & finalRating & " out of 5"
  116.  
  117. for i = 1 to CInt(finalRating)
  118. Response.Write "<img alt='" & altText & "' src='rating_on.gif'>"
  119. next
  120.  
  121. if CInt(finalRating) <> finalRating then
  122. 'This article has a .5 rating, such as 5.5
  123. Response.Write "<img alt='" & altText & "' src='rating_half.gif'>"
  124.  
  125. for i = CInt(finalRating)+2 to 10
  126. Response.Write "<img alt='" & altText & "' src='rating_off.gif'>"
  127. next
  128. else
  129. for i = CInt(finalRating)+1 to 10
  130. Response.Write "<img alt='" & altText & "' src='rating_off.gif'>"
  131. next
  132. end if 
  133. end function
  134.  
  135. if CInt(finalRating) <> finalRating then
  136. 'This article has a .5 rating, such as 5.5
  137. Response.Write "<img alt='" & altText & "' src='rating_half.gif'>"
  138.  
  139.  
  140. %>
  141.  
  142. <h2><%=Recordset2.Fields(0).Value%></h2>
  143.  
  144. <br>
  145. <br>  
  146. <%end if%>
  147. <%
  148. While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF)) 
  149. %> 
  150.  <table width="52%" border="0" cellspacing="4" cellpadding="0">
  151.     <tr>
  152.     <td width="39%" rowspan="6" align="left" valign="top"><img src="images\album_pics\<%=(Recordset1.Fields.Item("cd_image").Value)%>">
  153.     <tr>
  154.       <tr>
  155.         <td width="39%" rowspan="6" align="left" valign="top">&nbsp;</td>
  156.         <td width="28%"><strong>Album:</strong></td>
  157.         <td width="33%"><div align="left"><%=(Recordset1.Fields.Item("cd_title").Value)%></div></td>
  158.       </tr>
  159.       <tr>
  160.         <td><strong>Artist:</strong></td>
  161.         <td><div align="left"><%=(Recordset1.Fields.Item("artist_name").Value)%></div></td>
  162.       </tr>
  163.       <tr>
  164.         <td><strong>Release date:</strong></td>
  165.         <td><div align="left"><%=(Recordset1.Fields.Item("release_date").Value)%></div></td>
  166.       </tr>
  167.       <tr>
  168.         <td><strong>Genre:</strong></td>
  169.         <td><div align="left"><%=(Recordset1.Fields.Item("music_genre").Value)%></div></td>
  170.       </tr>
  171.       <tr>
  172.         <td><p><strong>Artist Biography</strong>:</p></td>
  173.       </tr>
  174.       <tr>
  175.         <td colspan="3"></td>
  176.       <tr>
  177.         <td align="left" valign="top"><%=(Recordset1.Fields.Item("artist_biography").Value)%></td>
  178.         <td colspan="3">&nbsp;</td>
  179.       <tr>
  180.         <td colspan="5" align="left" valign="top"><div align="right">Rated: <%=ShowRating(Recordset2.Fields(0).Value)%>
  181.  
  182.       </div></td>
  183.       <tr>
  184.         <td colspan="4" align="left" valign="top">
  185.           <form name="frmRate<%=recordset1.Fields(0).value%>" action="rate.asp" method="post">
  186.           <input type="hidden" name="cdid" value="<%=(recordset1.Fields(0).value)%>">
  187.             <table width="100%" border="0" cellspacing="0" cellpadding="0">
  188.             <tr>
  189.                 <td colbgcolor="white">
  190.                   <p><font face="Verdana" size="3" color="orange">
  191.                     Dont buy this
  192.                     <input type ="radio" name="rating" value="1" >
  193.                     <input type ="radio" name="rating" value="2" >
  194.                     <input type ="radio" name="rating" value="3" >
  195.                     <input type ="radio" name="rating" value="4" >
  196.                     <input type ="radio" name="rating" value="5" >
  197.                       You must buy this
  198.  
  199.                     <p>
  200.                     <input type="submit" value="Rate It!">            
  201.                   </p></td>
  202.             </tr>
  203.             </table>  
  204.           </form></td>
  205.       <tr>
  206.         <td colspan="4" align="left" valign="top"><hr></td>
  207.     </table>
  208.  
  209.     <div align="right"></div>
  210.     <% 
  211.   Repeat1__index=Repeat1__index+1
  212.   Repeat1__numRows=Repeat1__numRows-1
  213.   Recordset1.MoveNext()
  214. Wend
  215. %>
  216. </div>
  217. <p>&nbsp;Next</p>
  218. </body>
  219. </html>
  220. <%
  221. Recordset1.Close()
  222. Recordset2.Close()
  223. Set Recordset1 = Nothing
  224. Set Recordset2 = Nothing
  225. %>
  226. <%
  227.  
  228.  
  229. %>
  230.  
  231.  
  232.  
Jan 17 '08 #1
10 7699
idsanjeev
241 100+
Hi Jasone
Try to add where are you excute at line 80 and don't get any error at line 16


Expand|Select|Wrap|Line Numbers
  1. conn, adOpenStatic, adLockReadOnly, adCmdText
let me know if it work
Jan 17 '08 #2
jasone
66
Hi,

Thanks for your reply,

i was a little unsure where you wanted me to try this line of code, and if anything needed to be added removed with the line.

i have added it on line 81, below the sql select statement as shown:

Expand|Select|Wrap|Line Numbers
  1.  
  2. set conn = Server.CreateObject("ADODB.Connection") 
  3. set Recordset2 = Server.CreateObject("ADODB.Recordset")
  4.  
  5. conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\inetpub\wwwroot\ddwassignment2\music_wor  ld.mdb"
  6.  
  7. Recordset2 = "SELECT SUM(rating), COUNT(*) FROM ratings WHERE cdid = " & cdid
  8. Recordset2 = conn, adOpenStatic, adLockReadOnly, adCmdText
  9.  
  10.  
  11. 'This CD has ratings, let's display the average
  12. avgRating = Recordset2.Fields(0).Value / Recordset2.Fields(1).Value 
  13.  
  14.  

and i am now getting the following error at run time:
__________________________________________________ _________
Expected end of statement
/ddwassignment2/full_catalogue2.asp, line 81, column 17
Recordset2 = conn, adOpenStatic, adLockReadOnly, adCmdText
adCmdText
__________________________________________________ _________

Thanks for your support !
Jan 17 '08 #3
idsanjeev
241 100+
Hi
try use same place
Expand|Select|Wrap|Line Numbers
  1. R.Open Recordset2, conn, adOpentatic, adLockReadOnly, adCmdTextS
Jan 17 '08 #4
jasone
66
Hi, thanks once again for your reply, it has reverted back to the object required error on line 180!
Jan 17 '08 #5
jasone
66
Hi, thanks once again for your reply, it has reverted back to the object required error on line 180!
Jan 17 '08 #6
idsanjeev
241 100+
hi
try to also add this code for your first recordset open at line 16
Jan 17 '08 #7
jasone
66
sorry, no effect by adding this line
Jan 17 '08 #8
idsanjeev
241 100+
Hi
I think line 180 has no any error so plz try to
Remove line then check in which line report error
thanks
Jan 18 '08 #9
jasone
66
Hi, thanks for all your help, it was decided to leave this out of the system due to lack of time
Feb 12 '08 #10
markrawlingson
346 Expert 100+
Ok, But FYI I just saw this post and here's your problem..

Expand|Select|Wrap|Line Numbers
  1.  
  2. set Recordset2 = Server.CreateObject("ADODB.Recordset")
  3.  
  4. conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\inetpub\wwwroot\ddwassignment2\music_wor  ld.mdb"
  5.  
  6. Recordset2 = "SELECT SUM(rating), COUNT(*) FROM ratings WHERE cdid = " & cdid
  7.  
  8.  
You're setting an OBJECT type variable, and then erasing it by setting its value to your SQL Statement - which is a string - thus when you call recordset2.fields(0).value - recordset2 isn't an object, it's a string. Thus - "object required"

Replace the above lines with this and it should work.

Expand|Select|Wrap|Line Numbers
  1.  
  2. conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\inetpub\wwwroot\ddwassignment2\music_wor  ld.mdb"
  3.  
  4. sSQL = "SELECT SUM(rating), COUNT(*) FROM ratings WHERE cdid = " & cdid
  5.  
  6. Set RecordSet2 = Server.CreateObject("ADODB.RecordSet")
  7.  
  8. RecordSet2.Open sSQL, Conn, adOpenReadOnly, adLockOptimistic, adCmdText
  9.  
  10.  
Now that you have an open recordset object, it should work.

Sincerely,
Mark
Feb 13 '08 #11

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by PaulieS | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.