Routine Motore di ricerca

giovedì 08 aprile 2004 - 11.36

Seagull Profilo | Newbie

Avrei bisogno di un suggerimento riguardante la seguente routine di un motore di
ricerca. La query di per sè non fa una grinza, se non che, pare che la routine non riesca ad
effettuare il controllo sulla stringa contenuta nell'ultimo campo del record
(cioè dell'ultimo elemento dell'array). Un Grazie in anticipo a chiunque volesse
prendere in considerazione il mio problema e chiedo scusa per la prolissità delle
righe del codice.




'##########ROUTINE MOTORE DI RICERCA PAROLE#############

Sub SearchResultsPanel()
Dim i 'Variabile indice
Dim objRs 'Variabile oggetto Recordset
Dim objCmd 'Variabile oggetto Command
Dim arrKeyword 'variabile array stringa
Dim strKeyword1 'variabile della stringa contenuta nel campo 1 del record
Dim strKeyword2 'variabile della stringa contenuta nel campo 2 del record
Dim strKeyword3 'variabile della stringa contenuta nel campo 3 del record
Dim strKeyword4 'variabile della stringa contenuta nel campo 4 del record
Dim strKeyword5 'variabile della stringa contenuta nel campo 5 del record
Dim strCategoryTitle '##Genere##
Dim intPageSize
Dim intRecord
Dim intPage



arrKeyword = Split(Request.QueryString("Keyword"), " ")
strKeyword1 = Null
strKeyword2 = Null
strKeyword3 = Null
strKeyword4 = Null
strKeyword5 = Null


i = UBound(arrKeyword)


If i = 4 Then
strKeyword1 = arrKeyword(0)
strKeyword2 = arrKeyword(1)
strKeyword3 = arrKeyword(2)
strKeyword4 = arrKeyword(3)
strKeyword5 = arrKeyword(4)

ElseIf i = 3 Then
strKeyword1 = arrKeyword(0)
strKeyword2 = arrKeyword(1)
strKeyword3 = arrKeyword(2)
strKeyword4 = arrKeyword(3)

ElseIf i = 2 Then
strKeyword1 = arrKeyword(0)
strKeyword2 = arrKeyword(1)
strKeyword3 = arrKeyword(2)

ElseIf i = 1 Then
strKeyword1 = arrKeyword(0)
strKeyword2 = arrKeyword(1)

Else
strKeyword1 = Request.QueryString("Keyword")

End If

If Not IsNull(IntToNull(Request.QueryString("CatID"))) Then
strCategoryTitle = CategoryTitle(Request.QueryString("CatID"))
Else
strCategoryTitle = Null
End If

intPageSize = 10
intRecord = 1
intPage = IntToNull(Request.QueryString("Page"))
If IsNull(intPage) Then intPage = 1

Set objCmd = Server.CreateObject("ADODB.Command")
Set objRs = Server.CreateObject("ADODB.Recordset")

With objCmd
.CommandText = "prc_RicercaFilms" 'Riferimento query database
.CommandType = adCmdStoredProc
Set .ActiveConnection = objCn

.Parameters.Append .CreateParameter("pCatID", adInteger, adParamInput, 4, IntToNull(Request.QueryString("CatID")))
.Parameters.Append .CreateParameter("pKeyword1", adVarWChar , adParamInput, 255, CharToNull(strKeyword1))
.Parameters.Append .CreateParameter("pKeyword2", adVarWChar, adParamInput, 255, CharToNull(strKeyword2))
.Parameters.Append .CreateParameter("pKeyword3", adVarWChar, adParamInput, 255, CharToNull(strKeyword3))
.Parameters.Append .CreateParameter("pKeyword4", adVarWChar, adParamInput, 255, CharToNull(strKeyword4))
.Parameters.Append .CreateParameter("pKeyword5", adVarWChar, adParamInput, 255, CharToNull(strKeyword5))
.Parameters.Append .CreateParameter("pLowDate", adDBDate, adParamInput, 8, DateToNull(Request.QueryString("LowDate")))
.Parameters.Append .CreateParameter("pHiDate", adDBDate, adParamInput, 8, DateToNull(Request.QueryString("HiDate")))
End With

With objRs
.CursorLocation = adUseClient
.Open objCmd, , adOpenStatic, adLockReadOnly
Set .ActiveConnection = Nothing
If Not .EOF Then
If Request.QueryString("View") = "4" Then
objRs.Sort = "DataAgg DESC, Genere ASC"
End If
objRs.PageSize = intPageSize
If intPage > objRs.PageCount Then intPage = objRs.PageCount
objRs.AbsolutePage = intPage
End If


End With

Brainkiller Profilo | Guru

Ciao, ho visto che hai selezionat come linguaggio VB.NET.
Ma il codice che hai postato è ancora scritto in ASP old-style, usando ADO normale.
Come suggerito da Marco ti consiglio prima di migrare il codice a .NET usando ADO.NET.

facci sapere.
ciao
david

Seagull Profilo | Newbie

Migrare? il seagull non è un uccello migratore raga......eppoi dopo che mi son fatto un paio di simil-classi e 6 o 7 moduli non mi và di far modifiche con una tecnologia che conosco poco.......per cui se avente un consiglio da darmi sulla routine va bene sennò...........grazie lo stesso, per lo meno mi avete risposto.

Brainkiller Profilo | Guru

Ciao Seagull,
non era per essere scortesi ma semplicemente per questo motivo, che con ASP.NET puoi effettuare debug delle applicazioni Web così come se si trattasse di una applicazione normale quindi procedere passo passo e capire perchè il codice va in errore o non si comporta come tu vorresti, invece che mettere cento mila Response.Write per capire cosa sta succedendo.
Infatti guardando così il codice bisogna debuggarlo in testa. Non conoscendo la struttura delle tabelle che stanno nel tuo DB è difficile darti una precisa soluzione. :-|

ciao
david
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5