ecco la funzioncina per togliere caratteri "fastidiosi" dalla stringa sql:
ed ecco una stringa sql che richiama la funzione prendendo dati da un form:codice:Function ChkString(str) ChkString = Replace(str, "'", "''") ChkString = Replace(str, "|", "||") End Function
Se mando in esecuzione questa stringa sql con valori contenenti apici ottengo il classico errore:codice:StrSql = "insert into pippo (nome, cognome, note) Values (" StrSql = StrSql & "'" & ChkString(Request.Form("nome")) & "', " StrSql = StrSql & "'" & ChkString(Request.Form("cognome")) & "', " StrSql = StrSql & "'" & ChkString(Request.Form("note")) & "')"
...Syntax error (missing operator) in query expression...
Come mai gli apici non vengono sostituiti dalla funzione?
Ma sopratutto, perchè il carattere | viene correttamente sostituito da || mentre il carattere ' non viene cambato?

Rispondi quotando
