Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

looping on database to get fields and tables

18 views
Skip to first unread message

thread

unread,
Feb 9, 2011, 3:36:16 PM2/9/11
to
Hi,
how can i get fields and tables by using ADO or DAO
is it posible by recordset and adodb connection
i'm talking about looping on database and not on a table that known
from the start
thats from advance

ralph

unread,
Feb 9, 2011, 5:29:59 PM2/9/11
to
On Wed, 9 Feb 2011 12:36:16 -0800 (PST), thread <yani...@gmail.com>
wrote:

What you are talking about comes under the general heading of "data
dictionary" services. Each database will provide its own services for
obtaining that information. So to adequately answer your question we
would need to know what database you are working with.

In general the ADO access library has little built-in DDL/DML
services. You can get some of these services using the ADO extension
library - ADOX. DAO on the other hand does, but is dependent on that
functionality being provided by the specific database ODBC driver.

But this is not chisel in stone. For example, if using SQL Server you
can use ADO with SQL to query system tables, the ADOX is not needed.
However, if using a Jet-formatted database then you will need to use
ADOX with ADO. DAO can be used to manage both.

-ralph

MikeD

unread,
Feb 10, 2011, 9:20:59 AM2/10/11
to

"thread" <yani...@gmail.com> wrote in message
news:cd756c8a-4422-4def...@x11g2000yqc.googlegroups.com...

You can use ADO for this. It will work for both SQL Server and Access
databases. I would assume it would also work with any "database" to which
you connect using the Jet Engine (Excel files, flat files, etc.). I believe
Ralph is incorrect about this. I know this will work for Access because
I've done it. I can also verify that this works with SQL Server CE.

To get tables into a recordset, you use ADO's OpenSchema method and specify
the adSchemaTables parameter.

Dim rsSchema As Recordset
Set rsSchema = oConn.OpenSchema(adSchemaTables)


To get tables AND fields, again use OpenSchema but specify adSchemaColumns:

Set rsFields = oConn.OpenSchema(adSchemaColumns)

For more information about the resultset returned by each of these, see
ADO's help (it should be in MSDN Library, but it'll be for an older version
of ADO, possibly 2.1). Or, you can just add the recordset object variable
to VB's Watch window.

--
Mike

ralph

unread,
Feb 10, 2011, 12:49:22 PM2/10/11
to
On Thu, 10 Feb 2011 09:20:59 -0500, "MikeD" <nob...@nowhere.edu>
wrote:

> ... I believe Ralph is incorrect about this.

Not necessarily incorrect but damn unenlightening. <g>

The OP was asking about "data dictionary" services. I should have
stopped right there. but I side-tracked into DDL because I got hung-up
on ADO and DAO and their differences - DAO provides DDL services, ADO
does not.

Might be interesting to know, but not germane to the OP's question.
Had I read my response before clicking Enter I might have been of some
help as well as saved myself some embarressment.

ADO does supply a method to access a database's dictionary - and it is
OpenSchema.

-ralph

0 new messages