artyom-beilis / cppcms

CppCMS Framework
Other
443 stars 107 forks source link

Cannot bind date in string format to SQL server datetime2 field #64

Open esidebo opened 4 years ago

esidebo commented 4 years ago

I create a statement on the form INSERT INTO table(date) VALUES(?) where date is of type datetime2 in my MSSQL table. When trying to bind to it with a std::string representing the date and time (e.g. like "2019-04-23 22:07:15.000000") I get the following error:

Operand type clash: text is incompatible with datetime2

Is this expected? I have no trouble binding a string to a datetime in mysql, it seems there is something special with datetime2. I can work around by passing the query to the session and encapsulating the datetime string with single quotes, but I would like to use a (prepared) statement since I'm doing this many times in a loop.