Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ODBC 3.0 issue - HY003 Program type out of range

322 views
Skip to first unread message

HScottBuck

unread,
Jun 6, 2006, 5:33:01 PM6/6/06
to
I'm trying to use ODBC to send data to SQL Server from VC++. When I try to
setup the parameters for sending a date to the database by calling
SQLBindParameters(), I get the error HY003 "Program type out of range".

This indicates that the 4th parameter, ValueType, is not correct. But I'm
hard coding it to a known valid value. Actually, I'm copying code strait
from the Microsoft Help and still getting this error.

Specifically, here's the lines of code:

DATE_STRUCT dsOpenDate;
SQLINTEGER cbOpenDate = 0;
SQLBindParameter (hstmt, 3, SQL_PARAM_INPUT, SQL_C_TYPE_DATE, SQL_TYPE_DATE,
0, 0, &dsOpenDate, 0, &cbOpenDate);

NOTE: This is from the sample in MS Help page:
ms-help://MS.VSCC.2003/MS.MSDNQTR.2005OCT.1033/odbc/htm/odbcsqlbindparameter.htm

So, according to the error, SQL_C_TYPE_DATE is not valid.

Looking into this further, SQL_C_TYPE_DATE is an ODBC 3.0 define. So,
thecking versions as such:

TRACE ("ODBCVER = %x\n", ODBCVER);
// makes "ODBCVER = 3.51" appear in the trace window.

TCHAR szResult[30];
SWORD nResult;
::SQLGetInfo (m_hdbc, SQL_ODBC_VER, szResult, sizeof(szResult), &nResult);
TRACE ("SQL_ODBC_VER = %s\n", szResult);
// makes SQL_ODBC_VER = 03.52 appear in the trace window.

So, I'm using a 3.0+ driver, I'm compiling with 3.0+ options. Do I need to
set some other option before it will work?

Any help would be appreciated,
Scott

Arnie

unread,
Jun 8, 2006, 11:46:43 AM6/8/06
to
"> DATE_STRUCT dsOpenDate;
> SQLINTEGER cbOpenDate = 0;
> SQLBindParameter (hstmt, 3, SQL_PARAM_INPUT, SQL_C_TYPE_DATE,
> SQL_TYPE_DATE,
> 0, 0, &dsOpenDate, 0, &cbOpenDate);
>
> NOTE: This is from the sample in MS Help page:
> ms-help://MS.VSCC.2003/MS.MSDNQTR.2005OCT.1033/odbc/htm/odbcsqlbindparameter.htm
>
> So, according to the error, SQL_C_TYPE_DATE is not valid.
>

Try
SQL_C_TYPE_TIMESTAMP

- Arnie


0 new messages