<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman,new york,times,serif;font-size:12pt">Hi,<br><br>I'm using pyodbc (Python 2.5) to insert records in an MS Access database. For security reasons, question marks should be used for string replacement [*]. The standard %s would make the code vulnerable to sql code injection. Problem is, string replacement in the Good Way somehow doesn't work when the values are dates. Below, snippet #1 does not work (Access says the inserted value is not consistent with the defined datatype), but #2 does. I tried various other ways (ie. DateValue, CDate, etc.) but none of them works. Is there a solution for this?<br><br><span>[*] see <a target="_blank" href="http://code.google.com/p/pyodbc/wiki/GettingStarted">http://code.google.com/p/pyodbc/wiki/GettingStarted</a> --&gt; under 'Parameters'</span><br><br>### 1<br>sql = "INSERT INTO tblSomeTable (myDate)
 VALUES (?);"<br>cursor.execute(sql, "#01/01/2010#")<br><br>### 2<br>sql = "INSERT INTO tblSomeTable (myDate) VALUES (%s);"<br>cursor.execute(sql % "#01/01/2010#")<br><div>&nbsp;</div>Cheers!!<br>Albert-Jan<br><br><div>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a fresh water system, and public health, what have the Romans ever done for us?<br>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<div><br></div></div>
</div><br>

      </body></html>