🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: ADO examples w Borland

#2712
From: Ivo Karindi
Date: Fri, 11 Apr 2003 15:30
91 lines
3856 bytes
Thanks for your help.  However, the example is not quite working yet on my
machine...  When I run the code I get the following error message:

Project ADOTEST1.exe raised exception class EOleException with message
'(this->get_Item(Index, (Adodb_tlb::FieldPtr*)&ppvObject)) Error: 800A0CC1
(-2146825023) @ ....

When I comment out everything starting with the line where "get_Item" is, it
works without errors (doing nothing), but when I write
Memo1->Lines->Add(rs->Fields->Count);

it writes 0 there although there are 2 fields and 6 records in my database.

Ivo Karindi


"Viatcheslav V. Vassiliev" <support@oledbdirect.com> wrote in message
news:3e96b0b5$1@newsgroups.borland.com...
> Import ADO type library (choose "Project\Import Type Library" in IDE
menu -
> choose "Microsoft ActiveX Data Objects 2.x Library"). Add button and memo
on
> your form
>
> #include <ADODB_TLB.h>
>
> void __fastcall TForm1::Button1Click(TObject *Sender)
> {
>  ConnectionPtr conn;
>  RecordsetPtr rs;
>
>  conn = CoConnection::Create();
>
>  conn->Open(WideString("Provider=Microsoft.Jet.OLEDB.4.0;Data
> Source=C:\\Temp\\Test.mdb;"),
>   WideString(""), WideString(""), 0);
>
>  rs = CoRecordset::Create();
>  rs->Open(WideString("Select * from [TableName]"), (IDispatch*)conn,
> adOpenKeyset, adLockOptimistic, 0);
>
>  rs->MoveFirst();
>  while (!(bool)rs->EOF)
>  {
>   for (int i=0; i<rs->Fields->Count; i++)
>   {
>    AnsiString str;
>    FieldPtr Field = rs->Fields->get_Item(i);
>    str = WideString(Field->Name) + WideString(" = ");
>    str += Field->get_Value();
>    Memo1->Lines->Add(str);
>   }
>   rs->MoveNext();
>
>   Memo1->Lines->Add("");
>  }
>
>  rs->Close();
>  conn->Close();
> }
>
> For this sample all columns should be convertible to string. You can use
> samples for VC or even for VB with some modifications.
>
> ----------------------------------------------------------------
> Regards,
> Viatcheslav V. Vassiliev
> http://www.oledbdirect.com
> The fastest way to access MS SQL Server, MS Jet (MS Access)
> and Interbase (through OLEDB) databases.
>
>
> "Ivo Karindi" <solk@ieslc.com> �������/�������� � �������� ���������:
> news:3e969069$1@newsgroups.borland.com...
> > Wondering if there are any ADO examples around on the 'net describing
the
> > use of ADO from C++B?  Something similar to what is available on
> > http://msdn.microsoft.com I'm using BCB4 and thus don't have ADOExpress.
> > And anyway I want to get my project done without having to use any
visual
> > components.
> >
> > Topics of interest are the following:
> > 1. Connecting to a MS Access 2000 database
> > 2. Retrieving records by running SQL
> >
> > Ivo Karindi
> >
> >
>
>
Technical Details
Message-ID: <3e96dfd7@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3e969069$1@newsgroups.borland.com> <3e96b0b5$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 10698b,ebf323db460718ac
X-Google-Attributes: gid10698b,public
X-Google-ArrivalTime: 2003-04-11 08:40:15 PST
Reply-To: "Ivo Karindi" <solk@ieslc.com>
From: "Ivo Karindi" <solk@ieslc.com>
Newsgroups: borland.public.cppbuilder.database.ado
References: <3e969069$1@newsgroups.borland.com> <3e96b0b5$1@newsgroups.borland.com>
Subject: Re: ADO examples w Borland
Date: Fri, 11 Apr 2003 18:30:15 +0300
Lines: 93
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 213.35.136.182
Message-ID: <3e96dfd7@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1050075095 213.35.136.182 (11 Apr 2003 08:31:35 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail