"Albert-Jan Roskam" <fo...@yahoo.com> wrote

dates. Below, snippet #1 does not work (Access says the inserted value is not
consistent with the defined datatype), but #2 does.

#2 is just normal string formatting so should always work.
But the cursor method is presumabnly doing some kind
of data type checking. What kind of data type does Access
normally expect for a date? Is it just a formatted string? Or
is there perhaps a numeric or datetime format that the
execute() might be expecting?

### 1
sql = "INSERT INTO tblSomeTable (myDate) VALUES (?);"
cursor.execute(sql, "#01/01/2010#")

### 2
sql = "INSERT INTO tblSomeTable (myDate) VALUES (%s);"
cursor.execute(sql % "#01/01/2010#")

HTH,

--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to