Lo all,
I'm having a little bit of trouble (betty...).
I have removed some of the obvious stuff from this example (like connections
being opened/closed etc)
I create a recordset in ASP (not linked to a database)
Set testRS = Server.CreateObject("ADODB.RecordSet")
testRS.Fields.Append "WebsiteID", adInteger
testRS.Fields.Append "WebsiteName", adVarchar, 20
testRS.Fields.Append "WebsiteDesc", adVarchar, 255
testRS.Fields.Append "WebsiteURL", adVarchar, 255
testRS.Fields.Append "Relevance", adInteger
testRS.Open
I then iterate through a secondset recordset (linked to a database) and dump
in all of my rows of data into my 'local' recordset.
Do While Not RS2.EOF
testRS.AddNew
testRS("WebsiteID") = RS2("WebsiteID")
testRS("WebsiteName") = RS2("WebsiteName")
testRS("WebsiteDesc") = RS2("WebsiteDesc")
testRS("WebsiteURL") = RS2("WebsiteURL")
testRS("Relevance") = RS2("Relevance")
testRS.Update
RS2.MoveNext
Loop
I now iterate through my local recordset and populate an array and look for
words with the string for each field (calling the GetSubstringCount
function)
Dim aFields(3)
testRS.MoveFirst
Do While Not testRS.EOF
aFields(0) = testRS("WebsiteName")
aFields(1) = testRS("WebsiteDesc")
aFields(2) = testRS("WebsiteMetaKeywords")
aFields(3) = testRS("WebsiteMetaDescription")
iCount = 0
For intLoop = 0 To UBound(aSearchCriteria)
For intLoop2 = 0 To UBound(aFields)
iCount = iCount + GetSubstringCount(aFields(intLoop2),
aSearchCriteria(intLoop), False)
Next
Next
testRS("Relevance") = iCount
testRS.Update
intTotalRelevance = intTotalRelevance + iCount
testRS.MoveNext
Loop
Ok - so thats pretty much the code, now then - my 'revelance' field for each
row needs to be a numeric value, initially I'd set this to be a Integer then
realised that I would get 12.35 as a result etc, so had a quick look at the
constants for the ado stuff and saw the adNumeric - which according to this
page :
http://www.able-consulting.com/ADODataTypeEnum.htm
can be used for the SQL Server version of Numeric/Decimal - so I figured I'd
use that...
So I've changed the above field appends to this :
Set testRS = Server.CreateObject("ADODB.RecordSet")
testRS.Fields.Append "WebsiteID", adInteger
testRS.Fields.Append "WebsiteName", adVarchar, 20
testRS.Fields.Append "WebsiteDesc", adVarchar, 255
testRS.Fields.Append "WebsiteURL", adVarchar, 255
testRS.Fields.Append "Relevance", adNumeric
But now everytime it runs I get this error :
Microsoft Cursor Engine error '80040e21'
Multiple-step operation generated errors. Check each status value.
/parasolit/statics/mainbody-search-results.asp, line 708
Line 708 is the line which tries to do this :
testRS("Relevance") = iCount
followed by
testRS.Update
When I leave it set as an integer its fine works ok but I dont get the
decimals, when I change it to numeric it goes tits up....
What I am trying to achieve is the population of at percentage value in
there - so if it goes and finds a couple of results they may be stored in
the local recordset (ready to dump to the page) like so :
58.35
41.65
etc etc
Can anyone see where I'm going wrong - I can post the entire page of code if
you want but its quite big and has lots of extra stuff not really relevant
to this problem.
Any info appreciated,
Regards
Rob