🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: How to read database column name ?

#81
From: Clayton Arends
Date: Wed, 13 Feb 2008 02:12
33 lines
2329 bytes
"nick" <nileiqi@hotmail.com> wrote in message 
news:47b24220$1@newsgroups.borland.com...

> How to read table's column name in database ? I think there is a way to do
> it.

If you want to get a table's column names then you can use the OpenSchema() 
method.  Its use is a little convoluted but once you understand how to use 
it all will be clear.  Here is an example:

  TADODataSet* dataSet = new TADODataSet(NULL);
  Variant columns[] = { Null(), Null(), WideString(tablename) };
  ADOConnection1->OpenSchema(siColumns, VarArrayOf(columns, 2),
    EmptyParam, dataSet);
  // iterate the dataset
  delete dataSet;

The result will have a bunch of fields describing almost everything you'll 
need to know about each column.  Each column is another record in the 
dataset.

VarArrayOf is a VCL function that creates a Variant Array from a simple 
array of variants.  The first parameter is the array and the second is the 
count minus 1.  EmptyParam is defined in <OleCtrls.hpp>.

Each query type that can be queried via OpenSchema expects a different 
number of constraints.  You can see a list for each (in the native ADO 
format) at:

  http://www.devguru.org/technologies/ADO/8548.asp

HTH,
Clayton 
Technical Details
Message-ID: <47b2520e$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news2.google.com!newshub.sdsu.edu!news.linkpendium.com!news.linkpendium.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <47b24220$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,635f0d823348c264
X-Google-Attributes: gid10698b,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Clayton Arends" <nospam_claytonarends@hotmail.com>
Newsgroups: borland.public.cppbuilder.database.ado
References: <47b24220$1@newsgroups.borland.com>
In-Reply-To: <47b24220$1@newsgroups.borland.com>
Subject: Re: How to read database column name ?
Date: Tue, 12 Feb 2008 18:12:22 -0800
Lines: 34
MIME-Version: 1.0
Content-Type: text/plain;
 format=flowed;
 charset="Windows-1252";
 reply-type=original
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Windows Mail 6.0.6000.16480
X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6000.16545
NNTP-Posting-Host: 68.185.45.89
Message-ID: <47b2520e$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1202868750 68.185.45.89 (12 Feb 2008 18:12:30 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news2.google.com!newshub.sdsu.edu!news.linkpendium.com!news.linkpendium.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail