Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ SQL » List DSN in ODBC
List DSN in ODBC [message #37517] Sun, 14 October 2012 04:38 Go to next message
luisrod0512 is currently offline  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 #37521 is a reply to message #37517] Sun, 14 October 2012 09:50 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Patch accepted (changed to Tuple2<String, String>).

BTW, why try-catch? Is there anything that can throw Exc?

Mirek
Re: List DSN in ODBC [message #37532 is a reply to message #37521] Mon, 15 October 2012 05:14 Go to previous message
luisrod0512 is currently offline  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()
Previous Topic: Automatic Upgrade MySQL schema
Next Topic: Store empty string to database
Goto Forum:
  


Current Time: Thu Mar 28 21:32:14 CET 2024

Total time taken to generate the page: 0.01115 seconds