Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


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

SQLGetData (odbc32)
 
.
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

TODO

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

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 PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions