all groups > sql server odbc > october 2005 >
You're in the

sql server odbc

group:

Writing a datetime


Writing a datetime Andrew Chalk
10/26/2005 12:42:47 AM
sql server odbc:
I have an SQL Server database that uses 'datetime' fields. I want to write
to these with SQLBindParameter(). What SQL type should I specify?

If I use SQL_TYPE_TIMESTAMP I get errors from SQLExecute() and
SQLGetDiagRec() states that there is an overflow.

Many thanks.

Re: Writing a datetime Richard Marsden
10/26/2005 7:23:20 AM
[quoted text, click to view]

I've managed to get dates to work by binding an SQL_DATE_STRUCT object
in SQLBindParameter. And you set the type to: SQL_C_TYPE_DATE.

TIME and TIMESTAMP should be similar (SQL_TIMESTAMP_STRUCT, etc.
You can then get/put the individual days,months,hours,etc from these
structures. (I have to map them to/from an existing date class that
the customer has provided me with)


Richard
--
Richard Marsden
Winwaed Software Technology, http://www.winwaed.com
Re: Writing a datetime Dmitriy Ivanov
10/26/2005 10:57:53 AM
Hello Andrew,
[quoted text, click to view]

AC> I have an SQL Server database that uses 'datetime' fields. I want
AC> to write to these with SQLBindParameter(). What SQL type should I
AC> specify?
AC>
AC> If I use SQL_TYPE_TIMESTAMP I get errors from SQLExecute() and
AC> SQLGetDiagRec() states that there is an overflow.

Have you tried SQL_TIMESTAMP instead?
--
Sincerely,
Dmitriy Ivanov
Common Lisp ODBC interface - www.ystok.ru

Re: Writing a datetime Andrew Chalk
10/27/2005 6:28:37 AM
I think that that is just the ODBC v2.0 name for the same thing.

- Andrew

[quoted text, click to view]

Re: Writing a datetime Andrew Chalk
10/27/2005 11:54:26 PM
It turned out that I was trying to initialize the 'year' member of the
TIMESTAMP struct to '105'. A value that is apparently too low. Adding 1900
fixed it.

- A
[quoted text, click to view]

AddThis Social Bookmark Button