We've porting code to Delphi XE2, and need to change our data access components from third party ODBCExpress which is no longer in business, to dbExpress's TSQLQuery.<br><br>We have parametrized SQL query such as:<br>
<br> sSQL :=<br> 'UPDATE ZTestData SET '+<br> ' StringField =?, '+<br> ' IntField = ?, '+<br> ' DecimalField = ?, '+<br> ' BooleanField = ?, '+<br> ' DateTimeField = ?, '+<br>
' TextField = ? '+<br> ' WHERE UniqueID = 3';<br><br>if we use the following code:<br><br>var<br> qry:TSQLQuery;<br>begin<br> qry.Close;<br> qry.SQL.Text := sSQL;<br> ShowMessage(IntToStr(qry.Params.Count));<br>
end;<br><br>It returns 0, so we're unable to get the bindings working, but if we change sSQL to:<br><br> sSQL :=<br>
'UPDATE ZTestData SET '+<br>
' StringField =:Param1, '+<br>
' IntField = :Param2, '+<br>
' DecimalField = ?, '+<br>
' BooleanField = ?, '+<br>
' DateTimeField = ?, '+<br>
' TextField = ? '+<br>
' WHERE UniqueID = 3';<br><br>It returns 2.<br><br>It's going to be a big hassle to change all the SQL queries to the new parameter syntax. Is there anyway for the TSQLQuery to recognize the ? syntax?<br>
<br>I see that DBXCommon.TDBXCommand uses the ? syntax:<br><br><a href="http://www.andreanolanusse.com/en/parameterized-queries-with-dbexpress-dbx-framework/">http://www.andreanolanusse.com/en/parameterized-queries-with-dbexpress-dbx-framework/</a><br>
<br>But it would mean throwing away our code that uses TSQLQuery. What's the quickest/easiest way to resolve this? What's the difference between TSQLQuery and TDBXCommand anyway, in terms of what's relevant to me?<br>
<br>Robo<br><br><br><br>