🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.database.ado
2 messages
2 total messages Started by nick Wed, 13 Feb 2008 00:04
How to read database column name ?
#80
Author: nick
Date: Wed, 13 Feb 2008 00:04
5 lines
890 bytes
Hi,

How to read table's column name in database ? I think there is a way to do it. Thanks.
nick
Re: How to read database column name ?
#81
Author: 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 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads