|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
ODBC insert of SQL_TYPE_TIMESTAMPI'm trying to insert a time stamp into SQL Server (2005) and can't figure out the right combination of column type and arguments to SQLBindParameter(). My C code currently looks like this: rc = SQLBindParameter(hstmt, 7, SQL_PARAM_INPUT, SQL_C_TYPE_TIMESTAMP, SQL_TYPE_TIMESTAMP, 10, 0, (SQLPOINTER)&tstamp, 0, NULL); I've tried different values for the ColumnSize and DecimalDigits parameters, including 10, 19, 22, 23, 26, and SQL_TIMESTAMP_LEN. As for the table definition, I've tried Datetime, char(10), char(19), etc. Different combinations either give me return codes of 22008 or 42S02. I definitely need to insert into a single column, as I'm trying to maintain compatibility with an equivalent DB2 database (which, if it helps, uses the DB2 TIMESTAMP data type, and has no problem with the above code). Info on the web for this problem is surprisingly scarce. I've found a few things but nothing concrete - so I'd really appreciate any help. Thanks in advance! Regards, Josh Hi LDJ
the timestamp datatype does not hold dates http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_ta-tz_6fn4.asp im not a C programmer so i have no idea wgat your code is doing, however if you want to store a date, DateTime is the data type you want to use. HTH -- Show quoteRegards Reg Besseling "LDJ" wrote: > Hi, > I'm trying to insert a time stamp into SQL Server (2005) and can't figure > out the right combination of column type and arguments to SQLBindParameter(). > > My C code currently looks like this: > rc = SQLBindParameter(hstmt, 7, SQL_PARAM_INPUT, > SQL_C_TYPE_TIMESTAMP, SQL_TYPE_TIMESTAMP, 10, 0, > (SQLPOINTER)&tstamp, 0, NULL); > I've tried different values for the ColumnSize and DecimalDigits parameters, > including 10, 19, 22, 23, 26, and SQL_TIMESTAMP_LEN. > > As for the table definition, I've tried Datetime, char(10), char(19), etc. > Different combinations either give me return codes of 22008 or 42S02. > > I definitely need to insert into a single column, as I'm trying to maintain > compatibility with an equivalent DB2 database (which, if it helps, uses the > DB2 TIMESTAMP data type, and has no problem with the above code). > > Info on the web for this problem is surprisingly scarce. I've found a few > things but nothing concrete - so I'd really appreciate any help. > > Thanks in advance! > Regards, > Josh Thanks Reg, but I was not using Timestamp. As I mentioned, I've tried
Datetime, and various char() definitions, none of which have worked so far... Thanks Reg, but I was not using Timestamp. I was using DateTime, and various
char() definitions, none of which worked.. Show quote "Reg Besseling" wrote: > Hi LDJ > > the timestamp datatype does not hold dates > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_ta-tz_6fn4.asp > > im not a C programmer so i have no idea wgat your code is doing, however if > you want to store a date, DateTime is the data type you want to use. > > HTH > -- > Regards > > Reg Besseling > > > "LDJ" wrote: > > > Hi, > > I'm trying to insert a time stamp into SQL Server (2005) and can't figure > > out the right combination of column type and arguments to SQLBindParameter(). > > > > My C code currently looks like this: > > rc = SQLBindParameter(hstmt, 7, SQL_PARAM_INPUT, > > SQL_C_TYPE_TIMESTAMP, SQL_TYPE_TIMESTAMP, 10, 0, > > (SQLPOINTER)&tstamp, 0, NULL); > > I've tried different values for the ColumnSize and DecimalDigits parameters, > > including 10, 19, 22, 23, 26, and SQL_TIMESTAMP_LEN. > > > > As for the table definition, I've tried Datetime, char(10), char(19), etc. > > Different combinations either give me return codes of 22008 or 42S02. > > > > I definitely need to insert into a single column, as I'm trying to maintain > > compatibility with an equivalent DB2 database (which, if it helps, uses the > > DB2 TIMESTAMP data type, and has no problem with the above code). > > > > Info on the web for this problem is surprisingly scarce. I've found a few > > things but nothing concrete - so I'd really appreciate any help. > > > > Thanks in advance! > > Regards, > > Josh |
|||||||||||||||||||||||