🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.ado
Article #3743

Cbuilder4 & Excell97

#3743
From: Shaun
Date: Tue, 02 Jul 2002 02:32
33 lines
1831 bytes
Hi,

I am trying to connect to Excel97 with CBuilder4 pro. I read a tutorial
online that explains how to do it with Access, I got this working with
Access but not excel. I need to extract some data from an excel spread sheet
and then after interaction with the user I want to post their selection to a
new spreadsheet.

heres the code I borrowed and altered,

TCOM_Connection cn = CoConnection::Create();
cn->ConnectionString = WideString("DSN=Test_").Detach();//excell odbc
cn->CursorLocation = Adodb_tlb::adUseClient;
cn->ConnectionTimeout = 100;
cn->Open(0,0,0,0);
WideString sql = "SELECT DISTINCT CITY from [Sheet$1]" ;//excell
ListBox1->Items->Clear();
TCOM_Recordset rs = CoRecordset::Create();
rs->Open(sql.Detach(), (IDispatch *)cn, Adodb_tlb::adOpenDynamic,
Adodb_tlb::adLockOptimistic, 0);
do
{
   Field* p = rs->Fields_->get_Item(TVariant("CITY"));
   String s =  p->get_Value();
   ListBox1->Items->Add(s);
   rs->MoveNext();
}while(rs->EOF == false);
rs->Close();
rs->Release();
cn->Close();
cn->Release();

Cheers Shaun
Technical Details
Message-ID: <3d210c8e$1_2@dnews>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!supernews.com!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnews

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10698b,d7212406486d45a7,start
X-Google-Attributes: gid10698b,public
X-Google-ArrivalTime: 2002-07-01 19:32:58 PST
From: "Shaun" <nospam@nospam.com>
Newsgroups: borland.public.cppbuilder.database.ado
Subject: Cbuilder4 & Excell97
Date: Tue, 2 Jul 2002 14:32:44 +1200
Lines: 35
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4133.2400
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
NNTP-Posting-Host: 202.50.240.154
Message-ID: <3d210c8e$1_2@dnews>
X-Trace: dnews 1025576078 202.50.240.154 (1 Jul 2002 19:14:38 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!supernews.com!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnews