Get DSN List in C++/CLI





1
Date Submitted Fri. Jun. 19th, 2009 6:55 AM
Revision 1 of 1
Beginner zywien
Tags C | cli | DllImport | odbc32.dll
Comments 0 comments
I saw a few samples where this was possible in C#, but nothing in C++/CLI. It should be fairly similar but there was one key difference... int instead of IntPtr.

#define SQL_SUCCESS                         0
#define SQL_SUCCESS_WITH_INFO      1
#define SQL_NO_DATA                         100
#define SQL_ERROR                                          (-1)
#define SQL_INVALID_HANDLE                  (-2)
#define SQL_STILL_EXECUTING          2
#define SQL_NEED_DATA            99
#define SQL_FETCH_NEXT        1
#define SQL_FETCH_FIRST    2

#define SQL_HANDLE_ENV        1
#define SQL_HANDLE_DBC        2
#define SQL_HANDLE_STMT    3
#define SQL_HANDLE_DESC    4

[System::Runtime::InteropServices::DllImport("odbc32.dll")]
extern "C" short _cdecl SQLAllocEnv(int% EnvironmentHandle);

[System::Runtime::InteropServices::DllImport("odbc32.dll")]
extern "C" short _cdecl SQLDataSources(int EnvironmentHandle, short Direction,  StringBuilder^ ServerName, short BufferLength1, short% NameLength1Ptr, StringBuilder^ Description, short BufferLength2, short% NameLength2Ptr);

[System::Runtime::InteropServices::DllImport("odbc32.dll")]
extern "C" short _cdecl SQLFreeHandle(short HandleType, int Handle);
 

Jarrod Zywien

Comments

There are currently no comments for this snippet.

Voting

Votes Up


Scripter elsevero

Votes Down