Article ID: 119487
Article Last Modified on 7/27/2001
SQLAllocEnv(&henv);
SQLAllocConnect (henv, &hdbc);
SQLDriverConnect (hdbc, hwnd, "", 0,
szConnStrOut,cbConnStrOutMax,&cbConnStrOut, SQL_DRIVER_PROMPT);
SQLAllocStmt(hdbc, &hstmt);
You can use either prepared execution or direct execution.
SQLPrepare(hstmt,"insert into test values(?)",SQL_NTS);
//Bind the parameter, define rgbValue to be a TIME_STRUCT
SQLBindParameter(hstmt,1,SQL_PARAM_INPUT, SQL_C_TIME,
SQL_TIMESTAMP,16,rgbValue,cbValueMax,
pcbValue);
//Set appropriate time values in the rgbValue
//Execute the prepared statement
SQLExecute(hstmt);
SQLExecDirect(hstmt,"insert into test values({t '10:10:10'})",SQL_NTS);
SQLFreeStmt (hstmt, SQL_DROP);
SQLDisconnect(hdbc);
SQLFreeConnect(hdbc);
SQLFreeEnv(henv);
When a select is executed on that table, the value returned is as expected,
with date part set to 0:
0000-00-00 10:10:10
//Bind the parameter, define rgbValue to be a TIMESTAMP_STRUCT SQLBindParameter(hstmt,1,SQL_PARAM_INPUT, SQL_C_TIMESTAMP,SQL_TIMESTAMP,16,rgbValue,cbValueMax,pcbValue);
SQLExecDirect(hstmt, "insert into test values({ts '1990-01-01
10:10:10'}",SQL_NTS)
This will set the date and time values correctly.
Additional query words: 1.01.1928 ODBC MSVC VC++ DDD
Keywords: kbbug KB119487