Hey!
Ik krijg de volgende melding:
'The connection cannot be used to perform this operation. It is either closed or invalid in this context.'
De search engine heb ik letterlijk ge-copy-pasted van 4guysfromrolla. Alleen de tabelnaam heb ik aangepast.
Hieronder allereerst mijn datastore include die open ik aan het begin van de pagina:
<%
Dim conntemp,dbpath,sqlString, objRS
'SQL
set conntemp=server.createobject("adodb.connection")
conntemp.Open "Provider=SQLOLEDB;SERVER=ALLMIGHTY;UID=sa;PWD=;Database=zoujewelwillenwetenhe"
%>
<%
'start tonen lijst met deelnemers
if request.querystring("status") <> "results" then
response.write "<font class=black09>Geef hieronder de achternaam van de persoon in die u zoekt. De lijst is gesorteerd op alfabetische volgorde van woonplaats.<BR><BR></font>"
response.write "<font class=black09><b>Achternaam:</b></font> <input type=text name=txtSearchString><BR>"
response.write "<BR><input type=submit value= Zoek >"
else
dim DefaultBoolean, RecordsPerPage, ID, adForwardOnly
'Set these up to your preference
DefaultBoolean = "AND"
RecordsPerPage = 10
'Get our form variable
Dim strSearch
strSearch = Request.form("txtSearchString")
'Get our current ID. This let's us know where we are Dim ID
ID = Request.QueryString("ID")
'Set up our SQL Statement
Dim strSQL, tmpSQL
strSQL = "SELECT * FROM NAWBezoeker WHERE "
tmpSQL = "(Description LIKE "
'OK, we need to parse our string here
Dim Pos
Pos = 1
While Pos > 0
Pos = InStr(1, strSearch," ")
If Pos = 0 Then
'We have hit the end
tmpSQL = tmpSQL & "'%" & strSearch & "%')"
Else
tmpSQL = tmpSQL & "'%" & Mid(strSearch,1,Pos) & "%' " & DefaultBoolean & " Description LIKE "
strSearch = Mid(strSearch,Pos+1,len(strSearch))
End If
Wend
'Now, we've got to make sure we only get the right records
strSQL = strSQL & tmpSQL & " AND ArticleURLID > " & ID
strSQL = strSQL & " ORDER BY ID" 'Important!
'Make our Recordset variable and get the results
Dim rsResults
Set rsResults = Server.CreateObject("ADODB.Recordset")
'Get the right number of records per page
rsResults.MaxRecords = RecordsPerPage
'Set our recordset properties (include ADOVBS.inc for the constant definitions!)
rsResults.CursorType = adForwardOnly
'Get our data
rsResults.Open strSQL
'OK, we've got the data, let's display it in HTML
'First, though, let's get the total number of records
Dim rsTotalRecords
strSQL = "SELECT COUNT(
FROM NAWBezoeker WHERE " & tmpSQL
Set rsTotalRecords = conntemp.Execute(strSQL)
'We also need the max ID value for our search Dim rsMaxID
strSQL = "SELECT MAX(ArticleURLID) FROM ArticleURL WHERE " & tmpSQL
Set rsMaxID = conntemp.Execute(strSQL)
'HIER GAAN WE DE RESULTATEN TONEN!
if rsResults.EOF then 'No matches found
%>
No matches found! Try broadening your search criteria.<P>
<A HREF="SearchStart.htm">Return to Search</A>
<%
Else
Dim iCurrentID
While Not rsResults.EOF
iCurrentID = rsResults("ArticleURLID") %>
<A HREF="<%=rsResults("URL")%>"> <%=rsResults("Title")%></A>
<%=rsResults("Description")%>
<% rsResults.MoveNext
Wend %>
<P>
<%=rsTotalRecords(0)%> Found!<BR>
<%
if iCurrentID < rsMaxID(0) then %>
<!-- We have at least another record... -->
<FORM METHOD=POST ACTION="Search.asp?ID=<%=iCurrentID%>">
<INPUT TYPE=HIDDEN NAME="txtSearchString" VALUE="<%=Request.form("strSearchString")%>">
<INPUT TYPE=SUBMIT VALUE="Next">
</FORM>
<%
end if
end if
end if
%>
Wie kan mij helpen met het oplossen van deze foutmelding?
Ik weet niet wat ik fout doe...
Ik krijg de volgende melding:
'The connection cannot be used to perform this operation. It is either closed or invalid in this context.'
De search engine heb ik letterlijk ge-copy-pasted van 4guysfromrolla. Alleen de tabelnaam heb ik aangepast.
Hieronder allereerst mijn datastore include die open ik aan het begin van de pagina:
<%
Dim conntemp,dbpath,sqlString, objRS
'SQL
set conntemp=server.createobject("adodb.connection")
conntemp.Open "Provider=SQLOLEDB;SERVER=ALLMIGHTY;UID=sa;PWD=;Database=zoujewelwillenwetenhe"
%>
<%
'start tonen lijst met deelnemers
if request.querystring("status") <> "results" then
response.write "<font class=black09>Geef hieronder de achternaam van de persoon in die u zoekt. De lijst is gesorteerd op alfabetische volgorde van woonplaats.<BR><BR></font>"
response.write "<font class=black09><b>Achternaam:</b></font> <input type=text name=txtSearchString><BR>"
response.write "<BR><input type=submit value= Zoek >"
else
dim DefaultBoolean, RecordsPerPage, ID, adForwardOnly
'Set these up to your preference
DefaultBoolean = "AND"
RecordsPerPage = 10
'Get our form variable
Dim strSearch
strSearch = Request.form("txtSearchString")
'Get our current ID. This let's us know where we are Dim ID
ID = Request.QueryString("ID")
'Set up our SQL Statement
Dim strSQL, tmpSQL
strSQL = "SELECT * FROM NAWBezoeker WHERE "
tmpSQL = "(Description LIKE "
'OK, we need to parse our string here
Dim Pos
Pos = 1
While Pos > 0
Pos = InStr(1, strSearch," ")
If Pos = 0 Then
'We have hit the end
tmpSQL = tmpSQL & "'%" & strSearch & "%')"
Else
tmpSQL = tmpSQL & "'%" & Mid(strSearch,1,Pos) & "%' " & DefaultBoolean & " Description LIKE "
strSearch = Mid(strSearch,Pos+1,len(strSearch))
End If
Wend
'Now, we've got to make sure we only get the right records
strSQL = strSQL & tmpSQL & " AND ArticleURLID > " & ID
strSQL = strSQL & " ORDER BY ID" 'Important!
'Make our Recordset variable and get the results
Dim rsResults
Set rsResults = Server.CreateObject("ADODB.Recordset")
'Get the right number of records per page
rsResults.MaxRecords = RecordsPerPage
'Set our recordset properties (include ADOVBS.inc for the constant definitions!)
rsResults.CursorType = adForwardOnly
'Get our data
rsResults.Open strSQL
'OK, we've got the data, let's display it in HTML
'First, though, let's get the total number of records
Dim rsTotalRecords
strSQL = "SELECT COUNT(
Set rsTotalRecords = conntemp.Execute(strSQL)
'We also need the max ID value for our search Dim rsMaxID
strSQL = "SELECT MAX(ArticleURLID) FROM ArticleURL WHERE " & tmpSQL
Set rsMaxID = conntemp.Execute(strSQL)
'HIER GAAN WE DE RESULTATEN TONEN!
if rsResults.EOF then 'No matches found
%>
No matches found! Try broadening your search criteria.<P>
<A HREF="SearchStart.htm">Return to Search</A>
<%
Else
Dim iCurrentID
While Not rsResults.EOF
iCurrentID = rsResults("ArticleURLID") %>
<A HREF="<%=rsResults("URL")%>"> <%=rsResults("Title")%></A>
<%=rsResults("Description")%>
<% rsResults.MoveNext
Wend %>
<P>
<%=rsTotalRecords(0)%> Found!<BR>
<%
if iCurrentID < rsMaxID(0) then %>
<!-- We have at least another record... -->
<FORM METHOD=POST ACTION="Search.asp?ID=<%=iCurrentID%>">
<INPUT TYPE=HIDDEN NAME="txtSearchString" VALUE="<%=Request.form("strSearchString")%>">
<INPUT TYPE=SUBMIT VALUE="Next">
</FORM>
<%
end if
end if
end if
%>
Wie kan mij helpen met het oplossen van deze foutmelding?
Ik weet niet wat ik fout doe...