473,322 Members | 1,911 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Object required error

229 100+
Hi, I am trying to add a small count code snippet


Expand|Select|Wrap|Line Numbers
  1. <%
  2.  dim rst
  3. 'on error resume next
  4.     set rst=conn.execute("Select count(*) from tblWatches where watchedProfileID = " & rs("ProfileID"))
  5.  
  6.     if rst(0)> 0 then
  7.         response.Write "<b>" & rst(0) & "  follower(s)</b> "
  8.     end if
  9.     rst.close
  10. %>
  11.  

into the page like


Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3.  
  4.   <%
  5.  
  6.  
  7.  
  8. Option Explicit
  9.  
  10. '************************************************************************************
  11. '* Declaration section
  12. '************************************************************************************
  13. ' Mode contstants
  14. Const MODE_DEFAULT     = 1
  15. Const MODE_RESULTS     = 2
  16.  
  17. Const DB_NAME        = "SQLServer"    ' Name of our database file
  18. Const SCRIPT_NAME    = ""    ' Name of this script
  19.  
  20. Const RECORDS_PER_PAGE     = 50            ' Number of records per page
  21.  
  22. Dim nMode    ' Current Mode
  23.  
  24.  
  25.  
  26.  
  27. ' This function will generate our connection string
  28. ' it assumes that Access database is in the same folder as this script
  29. Private Function GetConnectionString()
  30.  
  31. 'dim gstrConnectToDatabase
  32. 'SQL Server 2000 - OLE DB
  33.  
  34.  
  35.  
  36.       GetConnectionString = "Provider=SQLOLEDB; bla bla bla"
  37.  
  38. End Function
  39.  
  40. ' Shows HTML page header
  41. Public Function OutputPageHeader()
  42.     %>
  43.  
  44.                    <!--
  45.     header
  46.        -->
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.     <%
  56. End Function
  57.  
  58. ' Shows HTML page footer
  59. Public Function OutputPageFooter()
  60.     %>
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69. </body>
  70. </html>
  71.  
  72.     <%
  73. End Function
  74.  
  75. ' This function will display the search form
  76. Private Function ShowSearchForm()
  77.     OutputPageHeader
  78.     %>
  79.  
  80.  
  81.     <%
  82.     OutputPageFooter
  83. End Function
  84.  
  85. ' This function will display the results of the search
  86. Private Function ShowResults()
  87.     Dim strConn    ' Database connection string
  88.     Dim SQLQuery     ' String that will have our SQL statments
  89.     Dim RS        ' Recordset object
  90.     Dim Keyword    ' Keyword for search
  91.     Dim nRecCount    ' Number of records found
  92.     Dim nPageCount    ' Number of pages of records we have
  93.     Dim nPage    ' Current page number
  94.     Dim currentcolumn
  95.     Dim intRecord
  96. Dim conn
  97.  
  98.  
  99.  
  100.  
  101.     ' Let's see what page are we looking at right now
  102.     nPage = CLng(Request.QueryString("Page"))
  103.  
  104.     ' Let's see what user wants to search for today :)
  105.     Keyword = Trim(Request.QueryString("Keyword"))
  106.  
  107.     ' define our SQL statment
  108.     ' we will be looking for all the records in tblItem table 
  109.     ' where ItemName contains our Keyword
  110.     ' do not forget to fix tick marks (single quotes) in our Keyword
  111. '    SQLQuery = "SELECT * FROM tblAppsLoginDatabaseBySmo L INNER JOIN tblAppsProfilesDatabaseBySmo P ON L.UserId = P.UserId WHERE  p.gallery LIKE '%" & Replace(gallery, "'", "''") & "%' and L.status='Active' and L.accept='Yes'"
  112.  
  113.     SQLQuery="Select all etc"
  114.  
  115.     SQLQuery= SQLQuery & "FROM tblAppsLoginDatabaseBySmo L inner JOIN tblAppsProfilesDatabaseBySmo P ON L.UserId = P.UserId left outer join"
  116. SQLQuery= SQLQuery & "(select WatchedProfileID, count(WatchedProfileID) results from tblWatches  group by WatchedProfileID) S on P.profileId = S.WatchedProfileId "
  117.  
  118.  
  119. SQLQuery= SQLQuery & " where  "
  120.  
  121.  
  122.     SQLQuery= SQLQuery & " bla"
  123.  
  124.  
  125. 'SQLQuery= SQLQuery & "order by L.latestvisit desc"
  126.  
  127.  
  128. 'and p.ProfileID in (Select WatchedProfileID from tblWatches where WatchingUserID = 0" & rs("UserID") & ")"
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.     ' Create our connection string
  137.     strConn = GetConnectionString()
  138.  
  139.     ' Time to create and open recordset
  140.     Set RS = Server.CreateObject("ADODB.Recordset")
  141.     RS.CursorLocation = 3 ' adUseClient         
  142.     RS.Open SQLQuery, strConn ' adOpenKeyset CursorType
  143.  
  144.     ' Start outputing HTML
  145.     'OutputPageHeader
  146.  
  147.  
  148.  
  149.  
  150.     ' Did we find anything?
  151.     If Not RS.Eof Then
  152.         ' Let's deal with our findings
  153.  
  154.         ' Get records count
  155.         nRecCount = RS.RecordCount
  156.  
  157.         ' Tell recordset to split records in the pages of our size
  158.         RS.PageSize = RECORDS_PER_PAGE
  159.  
  160.         ' How many pages we've got
  161.         nPageCount = RS.PageCount
  162.  
  163.         ' Make sure that the Page parameter passed to us is within the range
  164.         If nPage < 1 Or nPage > nPageCount Then
  165.             ' Ops - bad page number
  166.             ' let's fix it
  167.             nPage = 1            
  168.         End If
  169.  
  170.  
  171.                     %>
  172.  
  173.  
  174.  
  175.  
  176.  
  177. <!DOCTYPE html>
  178.  
  179.  
  180. <head>
  181.   <meta charset="utf-8" />
  182.  
  183.  
  184.  
  185. </head>
  186. <body class="slabtexted">
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206. <%
  207.  
  208.  
  209.     ' Position recordset to the page we want to see
  210.         RS.AbsolutePage = nPage
  211.  
  212.         ' Let's output our records                
  213.         ' Loop through records until it's a next page or End of Records
  214.                 Do While Not (RS.Eof OR RS.AbsolutePage <> nPage)
  215. Dim sNewsTitle
  216. sNewsTitle= rs("workingmethods")
  217.     Dim thumbnail 
  218.     thumbnail = rs("galleryimage1")
  219.  
  220.     Dim totalThumbnails 
  221.     totalThumbnails = 1
  222.     If Not IsBlank(rs("galleryimage1")) Then
  223.         totalThumbnails = 2
  224.         If Not IsBlank(rs("galleryimage2")) Then
  225.             totalThumbnails = 3
  226. If Not IsBlank(rs("galleryimage3")) Then
  227.             totalThumbnails = 4
  228.  
  229.         End If            
  230.         End If        
  231.     End If
  232.  
  233.      ' randomize()
  234.      ' Dim pictureNumber
  235.      ' pictureNumber = CInt((rnd() * totalThumbnails) + 1)
  236.  
  237.  
  238.     ' Change picture every second
  239.      Dim pictureNumber
  240.      pictureNumber = (second(Time) MOD totalThumbnails) +1
  241.  
  242.     If pictureNumber>totalThumbnails Then
  243.         pictureNumber = 1
  244.     End If
  245.  
  246.     If pictureNumber = 2 then
  247.         thumbnail = rs("galleryimage1")
  248.     End If
  249.  
  250.     If pictureNumber = 3 then
  251.         thumbnail = rs("galleryimage2")
  252.     End If
  253.  
  254. If pictureNumber = 4 then
  255.         thumbnail = rs("galleryimage3")
  256.     End If
  257.  
  258.  
  259.     If IsNull(thumbnail)  then
  260.         thumbnail = rs("galleryimage1")
  261.     End If
  262.  
  263.  If IsBlank(rs("galleryimage1")) or IsBlank(rs("galleryimage2")) or IsBlank(rs("galleryimage3")) or IsBlank(rs("galleryimage4")) or IsBlank(rs("galleryimage5")) or IsBlank(rs("galleryimage6")) Then
  264.  
  265.    %>
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272. <%
  273.  dim rst
  274.  
  275. 'on error resume next
  276.     set rst=conn.execute("Select count(*) from tblWatches where watchedProfileID = " & rs("ProfileID"))
  277.  
  278.  
  279.  
  280.  
  281.     if rst(0)> 0 then
  282.         response.Write "<b>" & rst(0) & "  follower(s)</b> "
  283.     end if
  284.     rst.close
  285. %>
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295. <%
  296.                             End If
  297.  
  298.  
  299.  
  300.   %>
  301.  
  302.  
  303.  
  304. <%
  305.  
  306.  
  307.  
  308.             ' Move on to the next record
  309.             RS.MoveNext
  310.         Loop  
  311.  
  312.  
  313.  
  314.           %>
  315.  
  316.  
  317.         <%
  318.     Else  
  319.         OutputPageHeader
  320.  
  321.         ' We did not find anything 
  322.                  Response.Write "<h1>"
  323.         Response.Write "" & Keyword & "  "
  324.                          Response.Write "</h1>"
  325.  
  326.  %>
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.     <%
  336.         Response.Write ""
  337.  
  338.  
  339.             %>
  340.  
  341.  
  342.  
  343.  
  344.  
  345.          <%
  346.  
  347.  
  348.  
  349.     '    Response.Write ""
  350.     End If
  351.  
  352.  
  353.  
  354.     ' Be nice - close the recordset
  355.     RS.Close
  356.  
  357.     ' Finish this page
  358.     OutputPageFooter
  359. End Function
  360. '************************************************************************************
  361. '* End of Functions section
  362. '************************************************************************************
  363. %> 
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  

I get an object required error. Microsoft VBScript runtime error '800a01a8' with conn line 277.


I wonder if anyone could point me in the right direction to re-write the snippet to fit in with the way the page is written or an easy way to add an object that's compatible.

Thanks
Richard
Apr 25 '13 #1

✓ answered by Rabbit

You need to first declare and create your connection object.

1 1922
Rabbit
12,516 Expert Mod 8TB
You need to first declare and create your connection object.
Apr 25 '13 #2

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

Similar topics

3
by: Apostolis K. | last post by:
At first I make a independend virtual directory wich I named app and I check Directory Browsing in the Virtual Directory Properties. Then I create with notepad global.asa and index.asp ...
3
by: News Groups | last post by:
Dear Group I am trying to use the following code to refer to a form and control on my form. I am supposed to be using VBSCRIPT for this code. I always get an "object required: 'document' " error:...
1
by: contact | last post by:
Hi, I'm trying to use the following to replace a text string in all the links on a page: var arrLinks = document.links; for(var LinkIterator = 0; LinkIterator < arrLinks.length; LinkIterator++)...
7
by: google | last post by:
I am trying to use the following ASP code to examine the file names in a folder: Dim fso, f, fl, s, fs Set fso = CreateObject("Scripting.FileSystemObject") Set f =...
2
by: RICHARD BROMBERG | last post by:
I am using Access 200. I have a form which includes text boxes L1, L2 and L3 And a table tblGrades with number fields L1, L2 and L3
7
by: imatts | last post by:
Hi can anyone help with this little problem. I have a simple script to swap between two divs on a page. It works perfectly in Firefox & Safari & Opera. It fails in IE 6 giving Object Required error...
4
by: tcnjdeluca | last post by:
Hello I am sorry if this is a really novice question, but I am virtually clueless when it comes to Javascript. I have a page that is running the "leightbox" script. I have modified the script as...
6
by: jatin32 | last post by:
Hi, I have below code on Form_Load() , I get one time error when I open this form. 424 Object required, please help ASAP. Option Compare Database Private Sub Form_Load()
5
by: ash2009 | last post by:
Hi, I am getting an object required error on IE6 Line: 1826 Char:3 Code:0 When I do view Source on my browser: here's what I see for line 1826: function navBarGetMousePosition(e){
0
by: ibrahim Nohbala | last post by:
Hello. I've written a small program in MS Access 2007 that calculates how many goods left in stock in 3 different units. For example, I have a product that has 3 units of measurement: gr,kg and...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.