Hi, I am trying to add a small count code snippet
into the page like
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
Code:
<%
dim rst
'on error resume next
set rst=conn.execute("Select count(*) from tblWatches where watchedProfileID = " & rs("ProfileID"))
if rst(0)> 0 then
response.Write "<b>" & rst(0) & " follower(s)</b> "
end if
rst.close
%>
into the page like
Code:
<%
Option Explicit
'************************************************************************************
'* Declaration section
'************************************************************************************
' Mode contstants
Const MODE_DEFAULT = 1
Const MODE_RESULTS = 2
Const DB_NAME = "SQLServer" ' Name of our database file
Const SCRIPT_NAME = "" ' Name of this script
Const RECORDS_PER_PAGE = 50 ' Number of records per page
Dim nMode ' Current Mode
' This function will generate our connection string
' it assumes that Access database is in the same folder as this script
Private Function GetConnectionString()
'dim gstrConnectToDatabase
'SQL Server 2000 - OLE DB
GetConnectionString = "Provider=SQLOLEDB; bla bla bla"
End Function
' Shows HTML page header
Public Function OutputPageHeader()
%>
<!--
header
-->
<%
End Function
' Shows HTML page footer
Public Function OutputPageFooter()
%>
</body>
</html>
<%
End Function
' This function will display the search form
Private Function ShowSearchForm()
OutputPageHeader
%>
<%
OutputPageFooter
End Function
' This function will display the results of the search
Private Function ShowResults()
Dim strConn ' Database connection string
Dim SQLQuery ' String that will have our SQL statments
Dim RS ' Recordset object
Dim Keyword ' Keyword for search
Dim nRecCount ' Number of records found
Dim nPageCount ' Number of pages of records we have
Dim nPage ' Current page number
Dim currentcolumn
Dim intRecord
Dim conn
' Let's see what page are we looking at right now
nPage = CLng(Request.QueryString("Page"))
' Let's see what user wants to search for today :)
Keyword = Trim(Request.QueryString("Keyword"))
' define our SQL statment
' we will be looking for all the records in tblItem table
' where ItemName contains our Keyword
' do not forget to fix tick marks (single quotes) in our Keyword
' 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'"
SQLQuery="Select all etc"
SQLQuery= SQLQuery & "FROM tblAppsLoginDatabaseBySmo L inner JOIN tblAppsProfilesDatabaseBySmo P ON L.UserId = P.UserId left outer join"
SQLQuery= SQLQuery & "(select WatchedProfileID, count(WatchedProfileID) results from tblWatches group by WatchedProfileID) S on P.profileId = S.WatchedProfileId "
SQLQuery= SQLQuery & " where "
SQLQuery= SQLQuery & " bla"
'SQLQuery= SQLQuery & "order by L.latestvisit desc"
'and p.ProfileID in (Select WatchedProfileID from tblWatches where WatchingUserID = 0" & rs("UserID") & ")"
' Create our connection string
strConn = GetConnectionString()
' Time to create and open recordset
Set RS = Server.CreateObject("ADODB.Recordset")
RS.CursorLocation = 3 ' adUseClient
RS.Open SQLQuery, strConn ' adOpenKeyset CursorType
' Start outputing HTML
'OutputPageHeader
' Did we find anything?
If Not RS.Eof Then
' Let's deal with our findings
' Get records count
nRecCount = RS.RecordCount
' Tell recordset to split records in the pages of our size
RS.PageSize = RECORDS_PER_PAGE
' How many pages we've got
nPageCount = RS.PageCount
' Make sure that the Page parameter passed to us is within the range
If nPage < 1 Or nPage > nPageCount Then
' Ops - bad page number
' let's fix it
nPage = 1
End If
%>
<!DOCTYPE html>
<head>
<meta charset="utf-8" />
</head>
<body class="slabtexted">
<%
' Position recordset to the page we want to see
RS.AbsolutePage = nPage
' Let's output our records
' Loop through records until it's a next page or End of Records
Do While Not (RS.Eof OR RS.AbsolutePage <> nPage)
Dim sNewsTitle
sNewsTitle= rs("workingmethods")
Dim thumbnail
thumbnail = rs("galleryimage1")
Dim totalThumbnails
totalThumbnails = 1
If Not IsBlank(rs("galleryimage1")) Then
totalThumbnails = 2
If Not IsBlank(rs("galleryimage2")) Then
totalThumbnails = 3
If Not IsBlank(rs("galleryimage3")) Then
totalThumbnails = 4
End If
End If
End If
' randomize()
' Dim pictureNumber
' pictureNumber = CInt((rnd() * totalThumbnails) + 1)
' Change picture every second
Dim pictureNumber
pictureNumber = (second(Time) MOD totalThumbnails) +1
If pictureNumber>totalThumbnails Then
pictureNumber = 1
End If
If pictureNumber = 2 then
thumbnail = rs("galleryimage1")
End If
If pictureNumber = 3 then
thumbnail = rs("galleryimage2")
End If
If pictureNumber = 4 then
thumbnail = rs("galleryimage3")
End If
If IsNull(thumbnail) then
thumbnail = rs("galleryimage1")
End If
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
%>
[B]
<%
dim rst
'on error resume next
set rst=conn.execute("Select count(*) from tblWatches where watchedProfileID = " & rs("ProfileID"))
if rst(0)> 0 then
response.Write "<b>" & rst(0) & " follower(s)</b> "
end if
rst.close
%>[/B]
<%
End If
%>
<%
' Move on to the next record
RS.MoveNext
Loop
%>
<%
Else
OutputPageHeader
' We did not find anything
Response.Write "<h1>"
Response.Write "" & Keyword & " "
Response.Write "</h1>"
%>
<%
Response.Write ""
%>
<%
' Response.Write ""
End If
' Be nice - close the recordset
RS.Close
' Finish this page
OutputPageFooter
End Function
'************************************************************************************
'* End of Functions section
'************************************************************************************
%>
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
Comment