Desktop Functions:

   Smart Device Functions:

Show Recent Changes
Subscribe (RSS)
Misc. Pages
Helpful Tools
Suggested Reading
Website TODO List
Support Forum
Download Visual Studio Add-In

Terms of Use
Privacy Policy
sqlgetdata (odbc32)
Returns part or all of one column of one row of a result set. (Useful for long data values.)

C# Signature:

    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:

public const int   SQL_C_CHAR      = 1;

Alternative Managed API:

Do you know one? Please contribute it!



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);
            string err = GetError();
            throw new Exception(err);
        return val.ToString();

SQLGetData on MSDN

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

Access directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version