🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: ADO examples w Borland

#2710
From: Viatcheslav V. Vassiliev
Date: Fri, 11 Apr 2003 11:25
67 lines
2930 bytes
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: <3e96b0b5$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!news-out.visi.com!petbe.visi.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail
References: <3e969069$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 05:20:28 PST
From: "Viatcheslav V. Vassiliev" <support@oledbdirect.com>
Newsgroups: borland.public.cppbuilder.database.ado
References: <3e969069$1@newsgroups.borland.com>
Subject: Re: ADO examples w Borland
Date: Fri, 11 Apr 2003 15:25:51 +0400
Lines: 69
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.247.201.57
Message-ID: <3e96b0b5$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1050063029 213.247.201.57 (11 Apr 2003 05:10:29 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!news-out.visi.com!petbe.visi.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail