I'm stuck while working on my programm.
The problem is the following:
My app is connecting to the SQL SERVER 2008r2 via ODBC driver and then executes INSERT statement. There're lots of params in it, but i'm stuck with inserting time data. DB has field which needs to be filled and that causes confuse. That Field has type time(0)
Here's the code which is
SQLDriverConnect (sqlconnectionhandle,NULL,(SQLWCHAR*)CONNECTION_STRING,1433;DATABASE=SOMEDB; UID=SOMEUSER;PWD=SOMEPWD;Trusted_Connection=Yes;",SQL_NTS,retconstring,1024,NULL,SQL_DRIVER_NOPROMPT))
SQLSetEnvAttr(sqlenvhandle,SQL_ATTR_ODBC_VERSION, (SQLPOINTER)SQL_OV_ODBC3, SQL_IS_INTEGER)
SQLLEN cbTime = sizeof(SQL_TIME_STRUCT);
Duration.hour = 00;
Duration.minute = 03;
Duration.second = 59;
wchar_t* insertStatement = L"INSERT INTO [SOMEDB].[dbo].[SOMETABLE] (...,[Duration], ...) VALUES (..., ?, ...)";
retCode = SQLBindParameter(sqlstatementhandle, 5, SQL_PARAM_INPUT, SQL_C_TYPE_TIME, SQL_TYPE_TIMESTAMP, SQL_TIME_LEN, 0, &Duration, 0, &cbTime);
retCode = SQLPrepare(sqlstatementhandle, insertStatement, SQL_NTS);
retCode = SQLExecute(sqlstatementhandle);
While debugging no error is noticed. Every last function returns SQL_SUCCESS which is good.
But when i look at table i with SQL Management Studio i see new row which was just added. But the problem is that field of interest has value and it's almost correct except that seconds = 00.
I've tried to fill structure with different values but result is still the same:
Looking forward for your answers,
After some more debugging i figured out that SQLExecute returns 1(SUCCESS_WITH_INFO)
message: message 0x00e5e420 L"[Microsoft][ODBC SQL Server Driver]Fractional truncation" wchar_t