Article View: borland.public.cppbuilder.database.ado
Article #4604Please help me with my odbc program !
From: tinyfool
Date: Tue, 06 Nov 2001 00:52
Date: Tue, 06 Nov 2001 00:52
70 lines
3053 bytes
3053 bytes
I write a program,my programm use some function in odbc32.dll.
when I call these function,every thing is working.
But every call with the function SQLDataSources twice will raise Exception .
I send my programm to my friend,his environment is winnt4+cb4. In this
environment will not raise any Exception.
But I use win2k + bcb5 +bcb5sp1+adosp1,how can i do ?
my programm:
#include <vcl.h>
#pragma hdrstop
#include <sql.h>
#include <sqlext.h>
#include "Unit1.h"
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
bool TForm1::GetDsn()
{
UWORD fDirection=SQL_FETCH_FIRST;
SQLCHAR szDSN[127];
SQLCHAR szDescription[127];
SQLRETURN retcode;
SQLHENV henv;
retcode=SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&henv);
if(retcode!=SQL_SUCCESS)
return FALSE;
retcode=SQLSetEnvAttr(henv,SQL_ATTR_ODBC_VERSION,(SQLPOINTER)SQL_OV_ODBC3,SQ
L_IS_INTEGER);
if(retcode!=SQL_SUCCESS)
return FALSE;
ListBox1->Items->Clear();
while(retcode==SQL_SUCCESS||retcode==SQL_SUCCESS_WITH_INFO)
{
retcode=SQLDataSources(henv,fDirection,(UCHAR*)szDSN,sizeof(szDSN),NULL,(UCH
AR*)szDescription,sizeof(szDescription),NULL);
fDirection=SQL_FETCH_NEXT;
if(retcode==SQL_SUCCESS||retcode==SQL_SUCCESS_WITH_INFO)
{
AnsiString dsn;
dsn.sprintf("%s",szDSN);
ListBox1->Items->Add(dsn);
}
}
SQLFreeHandle(SQL_HANDLE_ENV,henv);
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
GetDsn();
}
thank you!
--
China BCB beginner tinyfool
Welcome to my website
http://tinydust.yeah.net
Technical Details
Message-ID:
<3be73456_1@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!dnewsShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10698b,aee087b7d43292b2,start X-Google-Attributes: gid10698b,public X-Google-Thread: 1084ed,aee087b7d43292b2,start X-Google-Attributes: gid1084ed,public X-Google-Thread: fc5f9,aee087b7d43292b2,start X-Google-Attributes: gidfc5f9,public X-Google-Thread: 103c8d,aee087b7d43292b2,start X-Google-Attributes: gid103c8d,public X-Google-ArrivalTime: 2001-11-05 16:55:40 PST From: "tinyfool" <tinyfool@163.net> Newsgroups: borland.public.cppbuilder.database.ado,borland.public.cppbuilder.database.sqlservers,borland.public.cppbuilder.language,borland.public.cppbuilder.ms_compatibility Subject: Please help me with my odbc program ! Date: Tue, 6 Nov 2001 08:52:28 +0800 Lines: 80 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2919.6700 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 NNTP-Posting-Host: 61.181.178.79 Message-ID: <3be73456_1@dnews> X-Trace: dnews 1005007958 61.181.178.79 (5 Nov 2001 16:52:38 -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