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 previous 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..
 
Read Message
Read Message
Read Message
Previous Topic: Automatic Upgrade MySQL schema
Next Topic: Store empty string to database
Goto Forum:
  


Current Time: Sun Jul 14 13:47:42 CEST 2024

Total time taken to generate the page: 0.02678 seconds