Ecco tutto il codice che utilizzo:
codice:
QueryString = replace(ingrediente,"'"," ")
QueryWords = Split( QueryString )
strIndent = " "
sql = "SELECT * FROM ricette WHERE"
sql=sql &" ( [ingredienti] LIKE '%" & QueryWords( 0 ) & "%'" ' Prima
For i = LBound( QueryWords ) + 1 to UBound( QueryWords )
If QueryWords( i ) <> "" and UCase( QueryWords(i) ) <> "OR" and UCase( QueryWords(i) ) <> "AND" Then
If uCase( QueryWords( i-1 ) ) = "OR" Then
sql = sql & " OR [ingredienti] LIKE '%" & QueryWords( i ) & "%'"
Else
sql = sql & " AND [ingredienti] LIKE '%" & QueryWords( i ) & "%'"
End If
End If
Next
sql=sql &")"
sql = sql &" LIMIT " & (currentPage - 1) * pageSize & ", " & pageSize
set rs = cn.execute(sql)
ed ecco l'errore che restituisce
codice:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[MySQL][ODBC 3.51 Driver][mysqld-5.0.27-standard-log]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[ingredienti] LIKE '%fagioli%') LIMIT 0, 15' at line 1