Evitar inyeccion SQL

Hola.
Comparto el siguiente codigo.
Es una funcion que devuelve true si hay inyeccion y false si no la hay.

Me sirvio, espero les sirva.

dim first as integer
dim v as integer
dim todas(8) as string
dim i as integer
todas(0)="SELECT "
todas(1)="DROP "
todas(2)="INSERT "
todas(3)="UPDATE "
todas(4)="EXPLAIN "
todas(5)="REPLACE "
todas(6)="PRAGMA "
todas(7)="VACUUM "
todas(8)="DELETE "
cadena=trim(cadena)

v=0
for i=0 to 8
first = InStr(uppercase(cadena), todas(i))
if first = 0 then
v=0
else
v=1
exit for
end if
next i

if v=1 then
msgbox(“Se esta ingresando una instruccion SQL”)
return true
else
return false
end if

Esto es innecesario e incorrecto. Corres el riesgo de falsos positivos. Slo tiene que utilizar las declaraciones preparadas “prepared statements”.

Perdon, no entiendo, podrias ser un poco mas explicito?
Gracias

http://documentation.xojo.com/index.php/SQLitePreparedStatement

http://documentation.xojo.com/index.php/PreparedSQLStatement

No s necesario evaluar las entradas de Strings cuando usamos “Prepared Statements”, que ya nos protegen de las inyecciones maliciosas. El uso de su cdigo, introduciendo un texto real como “Let’s be pragmatic and update the page 133 of the manual” falsamente dir que es una tentativa de inyeccin SQL.