Greets!
Actually, this involves ASP as well, but I didn't want to cross-post to multiple categories. Let me know if I should.
I am getting the following error in my logs when folks search on my site:
Here is my code (please be nice!):
Perusing the interwebs, I've run into a number of suggestions to make this error go away. However, I wanted to be sure that my code was sufficient.. and that maybe there's a better way to go about searching.
Right now I'm thinking about performing these routines at the sql server level via stored procedures rather than with asp scripting. Supposedly doing that will possibly kill this problem as well as increase the speed of searching. Thoughts?
thanks for your time!
-S
Actually, this involves ASP as well, but I didn't want to cross-post to multiple categories. Let me know if I should.
I am getting the following error in my logs when folks search on my site:
Code:
ASP Error occurred 6/12/2009 12:25:23 PM in Microsoft OLE DB Provider for ODBC Drivers
Error number: -2147217900 (0x80040E14)
File: /inc_get_search_results.asp, line 75
[Microsoft][ODBC SQL Server Driver][SQL Server]Could not insert a row larger than the page size into a hash table. Resubmit the query with the ROBUST PLAN hint.
/forum_search.asp?
Here is my code (please be nice!):
Code:
PUBLIC Function sqlString(ByVal keywords)
Dim i
sqlString = "select distinct t.Forum_Topic_ID, t.Forum_Topic_Name, t.Forum_Topic_Replies, t.Forum_Topic_Lastpost, Account.Account_Username, t.forum_topic_locked, t.forum_topic_sticky, Forum_Category.forum_category_name, t.forum_category_ID, Account.account_id, t.forum_topic_date from forum_topic as t left join forum_reply as r on r.forum_topic_id= t.forum_topic_id, forum_category, forum, account "
if IsArray(keywords) then
if NOT bSearchTitles AND NOT bSearchDescriptions then
sqlString = TRIM(sqlString) & ";"
bNoFieldsToSearch = True
Exit Function
end if
sqlString = sqlString & "WHERE forum.Forum_ID='" & ForumID & "' AND (("
for i = 0 to UBOUND(keywords)
if bSearchTitles then sqlString = sqlString & _
"t.Forum_Topic_Name LIKE '%" & EscapeApostrophe(keywords(i)) & _
"%' " & SearchType & " "
next
if bSearchTitles AND bSearchDescriptions then
sqlString = Left(sqlString, Len(sqlString)-4)
sqlString = TRIM(sqlString)
sqlString = sqlString & " OR ("
end if
for i = 0 to UBOUND(keywords)
if bSearchDescriptions then sqlString = sqlString & _
"r.Forum_Reply_Post LIKE '%" & EscapeApostrophe(keywords(i)) & _
"%' " & SearchType & " " & _
"t.Forum_Topic_Post LIKE '%" & EscapeApostrophe(keywords(i)) & _
"%' " & SearchType & " "
next
sqlString = Left(sqlString, Len(sqlString)-4)
if SearchType = "OR" then sqlString = sqlString & " "
if bSearchTitles AND bSearchDescriptions then sqlString = sqlString & ") "
sqlString=sqlString & ")) "
end if
sqlString = sqlString & " and t.forum_category_id = forum_category.Forum_Category_ID and forum_category.forum_id = forum.Forum_ID and t.account_id = account.account_id ORDER BY t.Forum_Topic_Date DESC;"
End Function
Public Function MakeKeywordArray(ByVal sWordVarTmp)
Dim sDelim, x
sDelim = ","
if TRIM(sWordVarTmp) = "" then Exit Function
if not instr(sWordVarTmp, sDelim) then sDelim = " "
x = Split(sWordVarTmp, sDelim)
MakeKeywordArray = x
End Function
if len(Request("SearchPhrase")) > 0 and (bSearchTitles=true or bSearchDescriptions=true) then
if Request("type") <> "AND" AND Request("type") <> "OR" then
Request("type") = "AND"
end if
Dim strSQL
strSQL = sqlString( MakeKeywordArray( trimquotes(HTMLDecode(trim(Request("SearchPhrase")))) ))
Set dataConn = Server.CreateObject("ADODB.Connection")
dataConn.Open MM_FreeFastForumDSN_STRING
Set adoRS = Server.CreateObject("ADODB.Recordset")
adoRS.Open strSQL, dataConn, adOpenStatic, adLockReadOnly, adCmdText
TotalRecords = adoRs.RecordCount
if not adoRS.EOF then adoRS.Move((PageNumber * TopicsPerPage))
if not adoRS.EOF then
arrResults = adoRS.GetRows(TopicsPerPage)
TopicsExist=1
adoRS.Close
Set adoRS = nothing
dataConn.Close
set dataConn = nothing
else
adoRS.Close
Set adoRS = nothing
dataConn.Close
set dataConn = nothing
TopicsExist=0
end if
end if
Perusing the interwebs, I've run into a number of suggestions to make this error go away. However, I wanted to be sure that my code was sufficient.. and that maybe there's a better way to go about searching.
Right now I'm thinking about performing these routines at the sql server level via stored procedures rather than with asp scripting. Supposedly doing that will possibly kill this problem as well as increase the speed of searching. Thoughts?
thanks for your time!
-S