Article View: borland.public.cppbuilder.database.ado
Article #4588Re: how can I enumerate the odbc dsn and the OLE Provider Driver?
From: Yakunin V.V.
Date: Wed, 31 Oct 2001 16:46
Date: Wed, 31 Oct 2001 16:46
75 lines
3426 bytes
3426 bytes
/**
* Enumerates ODBC Data Source Names.
*/
void EnumDSN(TStrings* strsUser, TStrings* strsSystem)
{
SQLHANDLE henv;
RETCODE retcode;
SQLCHAR szDSNName[SQL_MAX_DSN_LENGTH + 1];
if(SQL_SUCCEEDED(SQLAllocHandle(SQL_HANDLE_ENV, NULL, &henv)))
{
// set the ODBC behavior version.
SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (SQLPOINTER)
SQL_OV_ODBC3, SQL_IS_INTEGER);
// Enumerate the user data sources.
retcode = SQLDataSources(henv, SQL_FETCH_FIRST_USER, szDSNName,
sizeof(szDSNName), NULL, NULL, 0, NULL);
while(SQL_SUCCEEDED(retcode))
{
if (strsUser) strsUser->Add((char*)szDSNName);
// Do the next one, if it exists.
retcode = SQLDataSources(henv, SQL_FETCH_NEXT, szDSNName,
sizeof(szDSNName), NULL, NULL, 0, NULL);
}
// Enumerate the system data sources.
retcode = SQLDataSources(henv, SQL_FETCH_FIRST_SYSTEM, szDSNName,
sizeof(szDSNName), NULL, NULL, 0, NULL);
while(SQL_SUCCEEDED(retcode))
{
if (strsSystem) strsSystem->Add((char*)szDSNName);
// Do the next one, if it exists.
retcode = SQLDataSources(henv, SQL_FETCH_NEXT, szDSNName,
sizeof(szDSNName), NULL, NULL, 0, NULL);
}
SQLFreeHandle(SQL_HANDLE_ENV, henv);
}
}
VVY
"tinyfool" <tinyfool@163.net> wrote in message news:3bd9f97a_2@dnews...
> I use Win2000,BCB 5 Enterprise Suite & BCB5 Update Pack 1 &
AdoExpress
> Upgrade1.
> Now I know I need SQLDataSources function,and I find sql.h in the
BCB's
> include path,and the odbc32.lib in BCB's lib path+"psdk\".So I add the
> odbc32.lib to my project.
> I write follow two lines:
>
> SQLHENV henv;
> SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&henv);
>
> Complie is success,but linker tell me "Unresolved external
> '_SQLAllocHandle' referenced from d:\BCB\test\unit1.obj". I use IMPLIB to
> make a new odbc32.lib. the new one is 19kb ,and BCB's odbc32.lib is
6.68kb.
> When I use the new lib and the sql.h ,I got the same error.
>
> What can I do ?Please help me!
> Thank you very much!
>
>
> --
> TinyFool
>
> A BCB beginer From China
>
>
>
>
Technical Details
Message-ID:
<3be02afc$1_2@dnews>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!news.maxwell.syr.edu!feed1.uncensored-news.com!propagator-la!news-in-la.newsfeeds.com!news-in.superfeed.net!newsfeed01.tsnz.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnewsReferences:
<3bd75dbc_2@dnews> <3bd7fe00_2@dnews> <3bd9f97a_2@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10698b,354a40a1af61bbdb X-Google-Attributes: gid10698b,public X-Google-ArrivalTime: 2001-10-31 09:01:58 PST Reply-To: "Yakunin V.V." <vvy@jensen.ru> From: "Yakunin V.V." <vvy@jensen.ru> Newsgroups: borland.public.cppbuilder.database.ado References: <3bd75dbc_2@dnews> <3bd7fe00_2@dnews> <3bd9f97a_2@dnews> Subject: Re: how can I enumerate the odbc dsn and the OLE Provider Driver? Date: Wed, 31 Oct 2001 19:46:57 +0300 Lines: 77 Organization: Jensen Technologies LLC X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 NNTP-Posting-Host: 212.113.107.55 Message-ID: <3be02afc$1_2@dnews> X-Trace: dnews 1004546812 212.113.107.55 (31 Oct 2001 08:46:52 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!news.maxwell.syr.edu!feed1.uncensored-news.com!propagator-la!news-in-la.newsfeeds.com!news-in.superfeed.net!newsfeed01.tsnz.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews