请问当SQLBindCol()中SQLSMALLINT TargetType=SQL_C_CHAR时,BufferLength,StrLen_or_IndPtr这两个参数的含义是什么?

解决方案 »

  1.   

    SQLBindCol binds application data buffers to columns in the result set.BufferLength 
    [Input]
    Length of the *TargetValuePtr buffer in bytes. StrLen_or_IndPtr 
    [Deferred Input/Output]
    Pointer to the length/indicator buffer to bind to the column.
      

  2.   

    BufferLength是你提供给sql的缓冲区大小,因为sql无法确定你给它的缓冲区有多大,所以你有必要指定一个大小以免数据过长而对缓冲区外的数据造成损坏.一般来说,你给它的字符串指针能有多大有效的长度就给它多长.比如之前你定义了TCHAR szBuffer[256],或char szBuffer[256],你就把BufferLength设成255
    strLen_or_IndPtr在你这种情况下,是说数据库实际往你的缓冲区里存了多少字符.