INSERT INTO problem

S

SU_Oran

This is on my HTML page

<td align=center>
<textarea cols="85" rows="7" name="Problem"></textarea>
</td>

User enters information into this box.

If they use either a quote or double quote, but SQL statement bombs. Is
there a way quick way to fix this beforehand?
Conn.execute ("INSERT INTO PROBLEMS (Problem) VALUES ('" & Problem & "')")

Thanks in advance
 
B

Bob Barrows [MVP]

SU_Oran said:
This is on my HTML page

<td align=center>
<textarea cols="85" rows="7" name="Problem"></textarea>
</td>

User enters information into this box.

If they use either a quote or double quote, but SQL statement bombs.
Is there a way quick way to fix this beforehand?
Conn.execute ("INSERT INTO PROBLEMS (Problem) VALUES ('" & Problem &
"')")
This is easily fixed by not using dynamic sql:


dim cmd, sSQL
sSQL = "INSERT INTO PROBLEMS (Problem) VALUES (?)"
set cmd=createobject("adodb.command")
cmd.commandtext=sSQL
set cmd.activeconnection=conn
cmd.Execute ,array(Problem),129

Bob Barrows
 
G

Gérard Leclercq

The best way is to use a stored procedure. Then you don't have to worry
about any kind of quotes.
More basic is
Conn.execute ("INSERT INTO PROBLEMS (Problem) VALUES (" & Chr(34) &
Replace("'","another value") & Chr(34))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top