Home All Groups Group Topic Archive Search About

ODBC insert of SQL_TYPE_TIMESTAMP

Author
11 Aug 2006 8:16 PM
LDJ
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

Author
11 Aug 2006 8:45 PM
Reg Besseling
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


Show quote
"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
Author
14 Aug 2006 1:06 PM
TPF
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...
Author
14 Aug 2006 1:12 PM
LDJ
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
Author
15 Aug 2006 3:12 PM
LDJ
Hi,
Unfortunately I'm still stuck on this - Please, does anyone have any other
advice?
Thank you,
Josh

AddThis Social Bookmark Button