<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2802" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>I got a problem where I am trying to insert a value 
into a database (ADO) using TAdoQeury which contains a single quote ( ' ) and 
setting a parameter.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Here goes :)</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV>I have a function written here which process's a sql command and sets the 
permiater IF it's value is over -1 here is the 
function.<BR><BR>//======================================<WBR>==========<WBR>====<BR>Procedure 
SetSqlTextD( ADOQ : TADOQuery; sqltxt : string; value : 
integer);<BR>Begin<BR>&nbsp; ADOQ.Active:=false;<BR>&nbsp; 
ADOQ.SQL.Clear;<BR>&nbsp; ADOQ.SQL.Text := sqltxt;<BR><BR>&nbsp; If value 
&lt;&gt; -1 then<BR>&nbsp; &nbsp; ADOQ.Parameters.ParamByName('SS').Value := 
value;<BR><BR>&nbsp; ADOQ.ExecSQL;<BR>&nbsp; 
ADOQ.Close;<BR>End;<BR>//======================================<WBR>==========<WBR>====<BR><BR>And 
you call it like this<BR>SetSqlTextD( AdoQ1, 'Update db SET field=" '+s+' " 
&nbsp;WHERE id=:SS', 102);<BR><BR>OR<BR>SetSqlTextD( AdoQ1, 'Update db SET 
field=" '+s+' " ', -1);<BR><BR>etc</DIV>
<DIV><BR>NOW<BR>if the second value is set to -1 then I can insert items with a 
', if the second value is over -1 then I get the error?<BR>So with the examples 
above, the first one would fail, the second one would work<BR>The error is, 
Paramiter SS is not set.<BR></DIV>
<DIV>note that if value s --&gt; smile's<BR>(single quote) then<BR>SetSqlTextD( 
AdoQ1, 'Update db SET field=" '+s+' " ', -1);<BR>That works<BR><BR>SetSqlTextD( 
AdoQ1, 'Update db SET field=" '+s+' " &nbsp;WHERE id=:SS', 102);<BR>That fails 
with paramter SS not set<BR><BR><BR>if value s --&gt; smile then<BR>(no quote) 
then<BR>SetSqlTextD( AdoQ1, 'Update db SET field=" '+s+' " &nbsp;WHERE id=:SS', 
102);<BR>works fine</DIV>
<DIV>&nbsp;</DIV>
<DIV>if value s --&gt; smile''s then<BR>(two single quotes) then<BR>SetSqlTextD( 
AdoQ1, 'Update db SET field=" '+s+' " &nbsp;WHERE id=:SS', 102);<BR>works fine 
BUT puts smile''s in the database, not smile's</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV></BODY></HTML>