none
ODBC 3.0 issue - HY003 Program type out of range RRS feed

  • Question

  • I tried posting this under "SQL Server Data Access" but did not get any response. I'm guess it's due to the C++ code.  So I'll try here:

    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

    Tuesday, June 6, 2006 8:14 PM

Answers

All replies