SQLGetData (odbc32)
Last changed: -187.34.154.92

.
Summary
Returns part or all of one column of one row of a result set. (Useful for long data values.)

C# Signature:

    [DllImport("odbc32.dll")]
    static extern short SQLGetData(IntPtr StatementHandle,
                   ushort ColumnNumber, short TargetType,
                   StringBuilder TargetValue, int BufferLength,
                   out int StrLen_or_Ind);

VB Signature:

<Runtime.InteropServices.DllImport("odbc32.dll")> _
    Private Shared Function SQLGetData(ByVal statementHandle As IntPtr, ByVal columnNumber As UShort, _
    ByVal targetType As Short, ByVal targetValue As IntPtr, ByVal bufferLength As Integer, _
    ByRef strLen_or_Ind As Integer) As Short
    End Function

User-Defined Types:

//data-types
public const int   SQL_C_CHAR      = 1;

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

    string GetFieldValue(ushort colid)
    {
        StringBuilder val = new StringBuilder(1024);
        int size;
        short rc = SQLGetData(statementHandle, colid, SQL_C_CHAR, val, val.Capacity, out size);
        if(rc!=0)
        {
            string err = GetError();
            throw new Exception(err);
        }
        return val.ToString();
    }

Documentation
SQLGetData on MSDN