Microsoft VBScript runtime (0x800A01A8) Object Required: "

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jasone
    New Member
    • Mar 2007
    • 66

    Microsoft VBScript runtime (0x800A01A8) Object Required: "

    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

    Code:
    <%@LANGUAGE="VBSCRIPT"%>
    <!--#include file="Connections/music_world.asp" -->
    
    
    
    <%
    Dim Recordset1
    Dim Recordset1_cmd
    Dim Recordset1_numRows
    
    Set Recordset1_cmd = Server.CreateObject ("ADODB.Command")
    Recordset1_cmd.ActiveConnection = MM_music_world_STRING
    Recordset1_cmd.CommandText = "SELECT * FROM tbl_cds" 
    Recordset1_cmd.Prepared = true
    
    Set Recordset1 = Recordset1_cmd.Execute
    Recordset1_numRows = 0
    %>
     
    <%
    dim rs1
    dim avgRating
    dim avgWhole
    dim decPart
    dim decCalc
    dim finalRating
    dim altText
    %>
    
    <%
    Dim Repeat1__numRows
    Dim Repeat1__index
    
    Repeat1__numRows = 5
    Repeat1__index = 0
    Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
    %>
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    <!--
    .style1 {
    	color: #FF6633;
    	font-weight: bold;
    }
    -->
    </style>
    
    </head>
    <body>
    
    <p align="left" class="style1">Full CD catalogue</p>
    <hr><hr>
    <p align="left" class="style1">&nbsp;</p>
    <div align="left">
     
    
    <%
    
    function ShowRating(cdid)
    
    const MIN_RATINGS_BEFORE_SHOW = 1
    
    dim Recordset2
    dim avgRating
    dim avgWhole
    dim decPart
    dim decCalc
    dim finalRating
    dim altText 
    dim conn
     
    set conn = Server.CreateObject("ADODB.Connection") 
    set Recordset2 = Server.CreateObject("ADODB.Recordset")
    
    conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\inetpub\wwwroot\ddwassignment2\music_world.mdb"
    
    Recordset2 = "SELECT SUM(rating), COUNT(*) FROM ratings WHERE cdid = " & cdid
    
    
    
    'This CD has ratings, let's display the average
    avgRating = Recordset2.Fields(0).Value / Recordset2.Fields(1).Value 
    
    if Instr(1, CStr(avgRating), ".") > 0 then
    
    'The average rating is a decimal, we need to either
    'round the value up/down
    
    avgWhole = Left(CStr(avgRating), Instr(1, CStr(avgRating), ".")-1)
    decPart = Mid(CStr(avgRating), Instr(1, CStr(avgRating), ".")+1, 2)
    
    if decPart <> "" then
    'Work out whether or not we have to round this
    'rating up or down
    
    if CInt(decPart) >= 5 then
    decCalc = .5
    else
    decCalc = 0
    end if
    
    finalRating = CInt(avgWhole) + CCur(decCalc)
    
    else
    finalRating = avgRating
    end if
    else
    finalRating = avgRating
    end if 
    
    'Setup the alt text for the images
    altText = "Average visitor rating of " & finalRating & " out of 5"
    
    for i = 1 to CInt(finalRating)
    Response.Write "<img alt='" & altText & "' src='rating_on.gif'>"
    next
    
    if CInt(finalRating) <> finalRating then
    'This article has a .5 rating, such as 5.5
    Response.Write "<img alt='" & altText & "' src='rating_half.gif'>"
    
    for i = CInt(finalRating)+2 to 10
    Response.Write "<img alt='" & altText & "' src='rating_off.gif'>"
    next
    else
    for i = CInt(finalRating)+1 to 10
    Response.Write "<img alt='" & altText & "' src='rating_off.gif'>"
    next
    end if 
    end function
    
    if CInt(finalRating) <> finalRating then
    'This article has a .5 rating, such as 5.5
    Response.Write "<img alt='" & altText & "' src='rating_half.gif'>"
    
    
    %>
    
    <h2><%=Recordset2.Fields(0).Value%></h2>
    
    <br>
    <br>  
    <%end if%>
    <%
    While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF)) 
    %> 
     <table width="52%" border="0" cellspacing="4" cellpadding="0">
        <tr>
        <td width="39%" rowspan="6" align="left" valign="top"><img src="images\album_pics\<%=(Recordset1.Fields.Item("cd_image").Value)%>">
        <tr>
          <tr>
            <td width="39%" rowspan="6" align="left" valign="top">&nbsp;</td>
            <td width="28%"><strong>Album:</strong></td>
            <td width="33%"><div align="left"><%=(Recordset1.Fields.Item("cd_title").Value)%></div></td>
          </tr>
          <tr>
            <td><strong>Artist:</strong></td>
            <td><div align="left"><%=(Recordset1.Fields.Item("artist_name").Value)%></div></td>
          </tr>
          <tr>
            <td><strong>Release date:</strong></td>
            <td><div align="left"><%=(Recordset1.Fields.Item("release_date").Value)%></div></td>
          </tr>
          <tr>
            <td><strong>Genre:</strong></td>
            <td><div align="left"><%=(Recordset1.Fields.Item("music_genre").Value)%></div></td>
          </tr>
          <tr>
            <td><p><strong>Artist Biography</strong>:</p></td>
          </tr>
          <tr>
            <td colspan="3"></td>
          <tr>
            <td align="left" valign="top"><%=(Recordset1.Fields.Item("artist_biography").Value)%></td>
            <td colspan="3">&nbsp;</td>
          <tr>
            <td colspan="5" align="left" valign="top">[B]<div align="right">Rated: <%=ShowRating(Recordset2.Fields(0).Value)%>[/B]
              
          </div></td>
          <tr>
            <td colspan="4" align="left" valign="top">
              <form name="frmRate<%=recordset1.Fields(0).value%>" action="rate.asp" method="post">
              <input type="hidden" name="cdid" value="<%=(recordset1.Fields(0).value)%>">
    			<table width="100%" border="0" cellspacing="0" cellpadding="0">
    			<tr>
    				<td colbgcolor="white">
    			      <p><font face="Verdana" size="3" color="orange">
                    	Dont buy this
                    	<input type ="radio" name="rating" value="1" >
                        <input type ="radio" name="rating" value="2" >
                        <input type ="radio" name="rating" value="3" >
                        <input type ="radio" name="rating" value="4" >
                        <input type ="radio" name="rating" value="5" >
    			      	You must buy this
    			   
                        <p>
    	                <input type="submit" value="Rate It!">			
    	              </p></td>
    			</tr>
    			</table>  
              </form></td>
          <tr>
            <td colspan="4" align="left" valign="top"><hr></td>
        </table>
        
        <div align="right"></div>
        <% 
      Repeat1__index=Repeat1__index+1
      Repeat1__numRows=Repeat1__numRows-1
      Recordset1.MoveNext()
    Wend
    %>
    </div>
    <p>&nbsp;Next</p>
    </body>
    </html>
    <%
    Recordset1.Close()
    Recordset2.Close()
    Set Recordset1 = Nothing
    Set Recordset2 = Nothing
    %>
    <%
    
    
    %>
  • idsanjeev
    New Member
    • Oct 2007
    • 241

    #2
    Hi Jasone
    Try to add where are you excute at line 80 and don't get any error at line 16


    [CODE=asp]conn, adOpenStatic, adLockReadOnly, adCmdText[/CODE]

    let me know if it work

    Comment

    • jasone
      New Member
      • Mar 2007
      • 66

      #3
      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:

      Code:
       
      set conn = Server.CreateObject("ADODB.Connection") 
      set Recordset2 = Server.CreateObject("ADODB.Recordset")
       
      conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\inetpub\wwwroot\ddwassignment2\music_wor  ld.mdb"
       
      Recordset2 = "SELECT SUM(rating), COUNT(*) FROM ratings WHERE cdid = " & cdid
      Recordset2 = conn, adOpenStatic, adLockReadOnly, adCmdText
       
       
      'This CD has ratings, let's display the average
      avgRating = Recordset2.Fields(0).Value / Recordset2.Fields(1).Value

      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 !

      Comment

      • idsanjeev
        New Member
        • Oct 2007
        • 241

        #4
        Hi
        try use same place
        Code:
        R.Open Recordset2, conn, adOpentatic, adLockReadOnly, adCmdTextS

        Comment

        • jasone
          New Member
          • Mar 2007
          • 66

          #5
          Hi, thanks once again for your reply, it has reverted back to the object required error on line 180!

          Comment

          • jasone
            New Member
            • Mar 2007
            • 66

            #6
            Hi, thanks once again for your reply, it has reverted back to the object required error on line 180!

            Comment

            • idsanjeev
              New Member
              • Oct 2007
              • 241

              #7
              hi
              try to also add this code for your first recordset open at line 16

              Comment

              • jasone
                New Member
                • Mar 2007
                • 66

                #8
                sorry, no effect by adding this line

                Comment

                • idsanjeev
                  New Member
                  • Oct 2007
                  • 241

                  #9
                  Hi
                  I think line 180 has no any error so plz try to
                  Remove line then check in which line report error
                  thanks

                  Comment

                  • jasone
                    New Member
                    • Mar 2007
                    • 66

                    #10
                    Hi, thanks for all your help, it was decided to leave this out of the system due to lack of time

                    Comment

                    • markrawlingson
                      Recognized Expert Contributor
                      • Aug 2007
                      • 346

                      #11
                      Ok, But FYI I just saw this post and here's your problem..

                      [code=asp]

                      set Recordset2 = Server.CreateOb ject("ADODB.Rec ordset")

                      conn.open "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=c:\inetp ub\wwwroot\ddwa ssignment2\musi c_wor ld.mdb"

                      Recordset2 = "SELECT SUM(rating), COUNT(*) FROM ratings WHERE cdid = " & cdid

                      [/code]

                      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.fiel ds(0).value - recordset2 isn't an object, it's a string. Thus - "object required"

                      Replace the above lines with this and it should work.

                      [code=asp]

                      conn.open "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=c:\inetp ub\wwwroot\ddwa ssignment2\musi c_wor ld.mdb"

                      sSQL = "SELECT SUM(rating), COUNT(*) FROM ratings WHERE cdid = " & cdid

                      Set RecordSet2 = Server.CreateOb ject("ADODB.Rec ordSet")

                      RecordSet2.Open sSQL, Conn, adOpenReadOnly, adLockOptimisti c, adCmdText

                      [/code]

                      Now that you have an open recordset object, it should work.

                      Sincerely,
                      Mark

                      Comment

                      Working...