ODBC SQLBindCol to TEXT field?

  • I am changing a VARCHAR(150) field to a TEXT field because we now do not want a limit on what we put in it. Performance hits aside, how in C++ what SQL_TYPE and length values do I need to put into what once was:

    SQLBindCol(hstmt, 1, SQL_C_CHAR, theField, 150, &cbTheField);

  • I've found the answer. I couldn't bind to a TEXT field. Instead I needed to repeatedly call SQLGetData():

    retcode = SQLPrepare(hstmt, L"SELECT theField FROM theTable WHERE thatOtherField= ?", SQL_NTS);

    SQLINTEGER cbthatOtherFieldValue = 0;

    retcode = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_GUID, SQL_GUID, 0, 0, &thatOtherFieldValue, 0, &cbthatOtherFieldValue);

    retcode = SQLExecute(hstmt);

    if (retcode == SQL_SUCCESS)

    {

    char final[8000];

    SQLINTEGER pIndicator;

    SQLFetch(hstmt);

    while(SQLGetData(hstmt,1,SQL_C_CHAR,final, sizeof(final),&pIndicator)==SQL_SUCCESS_WITH_INFO)

    {

    strcat(valueBack,final);

    }

    result = true;

    }

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply