grazie della risposta......
ho provato ma mi da il seguernte errore quando ridefinisco l'array nel secondo blocco di codice:
codice:
Tipo di errore:
Errore di run-time di Microsoft VBScript (0x800A000A)
Questa matrice è fissa o temporaneamente bloccata
/advsearch.asp, line 326
per chiarezza posto tutto il codice...
codice:
Dim strCampi,x,mag
set rsC = Server.CreateObject("ADODB.Recordset") ' estraggo i campi
mag = "magcamare"
Set RsC = Conn.OpenSchema(4, Array(Empty, Empty, "" & mag))
Dim arr_strCampi(15)
do while not rsC.eof
strCampi= rsC("COLUMN_NAME") ' metto i campi in un array
arr_strCampi(x) = strCampi
x=x+1
rsC.moveNext
loop
rsC.Close
Set rsC = Nothing
Set strCampi = Nothing
'response.Write strCampi
'response.End()
Dim stmSQL, tmpSQL
If OperatoreBol="fraseintera" Then ' costruisco le stringhe sql per il caso frase intera
stmSQL = "SELECT * FROM "&mag&" WHERE "
for xti = 0 to x-1
tmpSQL = "(" & arr_strCampi(xti)&" LIKE "
if xti=x-1 then
tmpSQL = tmpSQL & "'%" & ricerca & "%')"
else
tmpSQL = tmpSQL & "'%" & ricerca & "%') or "
end if
stmSQL = stmSQL & tmpSQL
next
Set x = Nothing
'Set arr_strCampi = Nothing
Elseif OperatoreBol="or" then ' costruisco le stringhe sql per il caso almeno una parola
stmSQL = "SELECT * FROM "&mag&" WHERE "
ArrayParole = Split(Trim(ricerca), " ")
for xti = 0 to x-1
For ContaParoleDaCercare = 0 to UBound(ArrayParole)
tmpSQL = "(" & arr_strCampi(xti)&" LIKE "
if xti = x-1 and ContaParoleDaCercare = UBound(ArrayParole) then
tmpSQL = tmpSQL & "'%" & ArrayParole(ContaParoleDaCercare) & "%' )"
else
tmpSQL = tmpSQL & "'%" & ArrayParole(ContaParoleDaCercare) & "%') " & OperatoreBol & " "
end if
stmSQL = stmSQL & tmpSQL
next
next
Set ArrayParole = Nothing
Set x = Nothing
'Set arr_strCampi = Nothing
Elseif OperatoreBol="and" then ' costruisco le stringhe sql per il caso tutte le parole
stmSQL = "SELECT * FROM "&mag&" WHERE ("
ArrayParole = Split(Trim(ricerca), " ")
for xti = 0 to x-1
For ContaParoleDaCercare = 0 to UBound(ArrayParole)
tmpSQL = arr_strCampi(xti)&" LIKE "
if xti = x-1 and ContaParoleDaCercare = UBound(ArrayParole) then
tmpSQL = tmpSQL & "'%" & ArrayParole(ContaParoleDaCercare) & "%' )"
else
if ContaParoleDaCercare = UBound(ArrayParole) then 'tolgo l'operatore dall'ultima sql
tmpSQL = tmpSQL & "'%" & ArrayParole(ContaParoleDaCercare) & "%' ) or ( "
else
tmpSQL = tmpSQL & "'%" & ArrayParole(ContaParoleDaCercare) & "%' " & OperatoreBol & " "
end if
end if
stmSQL = stmSQL & tmpSQL
next
next
Set ArrayParole = Nothing
Set x = Nothing
'Set arr_strCampi = Nothing
End If
Set mag = Nothing
Set tmpSQL = Nothing
'Costruisco la stringa finale dell'istruzione SQL
stmSQL = stmSQL & " order by descrizione, codice asc"
'response.write stmSQL
'response.End()
set elencamare=conn.execute(stmSQL)
Set stmSQL = Nothing
erase arr_strCampi