Skip to content

ODBC: DataFormatException getting Time value from SQL Server #3801

@MailShop

Description

@MailShop

Hi,

I get a DataFormatException getting time values from SQL Server. Example:

Session session("ODBC", "Driver=ODBC Driver 17 for SQL Server;Server=[...];Database=[...];Trusted_Connection=yes;");
session << "CREATE TABLE TimeTestTable (ok int, bad time)", now;
session << "INSERT INTO TimeTestTable (ok, bad) VALUES ( 1, '12:34:56')", now;
Statement s(session);
//s << "SELECT ok FROM TimeTestTable WHERE ok=1", now; //this works fine
s << "SELECT bad FROM TimeTestTable WHERE ok=1", now; //this throws DataFormatException("Unsupported data type.")
Poco::Data::RecordSet rs(s);

Looks like SQL Server's ODBC driver returns a custom type, SQL_SS_TIME2 (-154), rather than the standard value.
Not the only project to notice this problem: nanodbc/nanodbc#18

Pull request with a fix: #3802

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions