Home » U++ Library support » U++ SQL » List DSN in ODBC
List DSN in ODBC [message #37517] |
Sun, 14 October 2012 04:38  |
luisrod0512
Messages: 6 Registered: February 2012
|
Promising Member |
|
|
Congratulations to all of you for this great framework...
Here from Venezuela, I propuse some lines of code to make it better...
In ODBC.h
---------
class ODBCSession : public SqlSession {
public:
struct ListDSN
{
String name;
String description;
};
static Array<ListDSN> EnumDSN();
In ODBC.cpp
-----------
Array<ODBCSession::ListDSN> ODBCSession::EnumDSN()
{
Array<ODBCSession::ListDSN> out;
try {
SQLHENV MIenv;
SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &MIenv);
SQLSetEnvAttr(MIenv, SQL_ATTR_ODBC_VERSION, (void *) SQL_OV_ODBC3, 0);
SQLRETURN ret;
char l_dsn[256];
char l_desc[256];
short int l_len1,l_len2,l_next;
l_next=SQL_FETCH_FIRST;
while(SQL_SUCCEEDED(ret = SQLDataSources(MIenv,l_next,(SQLCHAR *)l_dsn, sizeof(l_dsn),
&l_len1, (SQLCHAR *)l_desc, sizeof(l_desc), &l_len2))) {
ListDSN& listdsn = out.Add();
listdsn.name = l_dsn;
listdsn.description = l_desc;
l_next=SQL_FETCH_NEXT;
}
}
catch(Exc e) {
LLOG("ODBC::GetDSN->" << e);
}
return out;
}
Thanks you for creating one of the best tool to develop software in C++ I've ever known.
Luis Rodriguez
Software Developer..
|
|
|
|
Re: List DSN in ODBC [message #37532 is a reply to message #37521] |
Mon, 15 October 2012 05:14  |
luisrod0512
Messages: 6 Registered: February 2012
|
Promising Member |
|
|
mirek wrote on Sun, 14 October 2012 09:50 | Patch accepted (changed to Tuple2<String, String>).
BTW, why try-catch? Is there anything that can throw Exc?
Mirek
|
In order not to change the standard existing in other Classes like <OleDB.cpp> which is used in SqlCommander application.
Array<OleDBSession::Provider> OleDBSession::EnumProviders()
|
|
|
Goto Forum:
Current Time: Fri Apr 25 12:13:39 CEST 2025
Total time taken to generate the page: 0.01076 seconds
|