dbTalk Databases Forums  

Objects in an Acces-Conn

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Objects in an Acces-Conn in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Christian Weber
 
Posts: n/a

Default Objects in an Acces-Conn - 08-11-2003 , 08:12 AM






Hi!

How can i get the name of all obejcts (queries, tables) in an existing
Access-Connection
and their structure (for tables the fiieldnames and datatypes, for queries
the SQL-statement).

I want to do this via ActiveX-Script.

Thanks!

greets

chris



Reply With Quote
  #2  
Old   
Darren Green
 
Posts: n/a

Default Re: Objects in an Acces-Conn - 08-11-2003 , 08:20 AM






You can do this with ADOX. Try something like-

Dim oCatalog
Set oCatalog = CreateObject("ADOX.Catalog")
For Each oTable In oCatalog.Tables
oTable..
Next



--
Darren Green
http://www.sqldts.com

"Christian Weber" <christian.weber (AT) siemens (DOT) com> wrote

Quote:
Hi!

How can i get the name of all obejcts (queries, tables) in an existing
Access-Connection
and their structure (for tables the fiieldnames and datatypes, for queries
the SQL-statement).

I want to do this via ActiveX-Script.

Thanks!

greets

chris





Reply With Quote
  #3  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: Objects in an Acces-Conn - 08-11-2003 , 08:24 AM



You are going to have to go into DAO and query the system catalogs from
there AFAIK (tabledefs). You can reference the DataSource property of your
Access connection to give you then name of the Access DB but that is about
all you can do with it for this.



--

----------------------------
Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org



"Christian Weber" <christian.weber (AT) siemens (DOT) com> wrote

Quote:
Hi!

How can i get the name of all obejcts (queries, tables) in an existing
Access-Connection
and their structure (for tables the fiieldnames and datatypes, for queries
the SQL-statement).

I want to do this via ActiveX-Script.

Thanks!

greets

chris





Reply With Quote
  #4  
Old   
Christian Weber
 
Posts: n/a

Default Re: Objects in an Acces-Conn - 08-11-2003 , 08:57 AM



Thanks!

How do i assign the "CreateObject("ADOX.Catalog")" to the connection?

greets

chris

"Darren Green" <darren.green (AT) reply-to-newsgroup-only (DOT) uk.com> schrieb im
Newsbeitrag news:uS5ygtAYDHA.1056 (AT) TK2MSFTNGP10 (DOT) phx.gbl...
Quote:
You can do this with ADOX. Try something like-

Dim oCatalog
Set oCatalog = CreateObject("ADOX.Catalog")
For Each oTable In oCatalog.Tables
oTable..
Next



--
Darren Green
http://www.sqldts.com

"Christian Weber" <christian.weber (AT) siemens (DOT) com> wrote in message
news:bh84mm$bbe$1 (AT) news (DOT) mch.sbs.de...
Hi!

How can i get the name of all obejcts (queries, tables) in an existing
Access-Connection
and their structure (for tables the fiieldnames and datatypes, for
queries
the SQL-statement).

I want to do this via ActiveX-Script.

Thanks!

greets

chris







Reply With Quote
  #5  
Old   
Darren Green
 
Posts: n/a

Default Re: Objects in an Acces-Conn - 08-11-2003 , 11:22 AM



In article <bh87aq$ll4$1 (AT) news (DOT) mch.sbs.de>, Christian Weber
<christian.weber (AT) siemens (DOT) com> writes
Quote:
Thanks!

How do i assign the "CreateObject("ADOX.Catalog")" to the connection?

greets

chris

Sorry, should have said, you can't use the connection directly, but you
can read off the properties from it and use it within the Catalog open
method. Here we grab a connection object and read off the filename from
it for use in the ADOX method.

Set oConn = DTSGlobalVariables.Parent.Connections("Conn name")

oCatalog.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
oConn.DataSource

MSDN provides a full ADOX reference, so have a look at that for more
detail of the objects and methods.

--
Darren Green (SQL Server MVP)
DTS - http://www.sqldts.com




Reply With Quote
  #6  
Old   
Darren Green
 
Posts: n/a

Default Re: Objects in an Acces-Conn - 08-12-2003 , 12:31 PM



In article <bha5d2$8gb$1 (AT) news (DOT) mch.sbs.de>, Christian Weber
<christian.weber (AT) siemens (DOT) com> writes
Quote:
Hi!

I get the error: "Method Open not supported."

I just cant go on at this point, im just a newbie to ADO.

greets

chris
There is no open method I was guessing. I have rarely used ADOX, but as
I said it is fully documented in MSDN. After a quick browse of the
relevant topics I came up with this-

Option Explicit

Function Main()

' Declare variables
Dim oPkg
Dim oConn
Dim sConnString
Dim oCatalog
Dim oTable

' Get reference to current package
Set oPkg = DTSGlobalVariables.Parent
' Get reference to Access connection, by name
Set oConn = oPkg.Connections("Microsoft Access")

' Build Access MDB connection string using DTS connection
sConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
_
oConn.DataSource

' Create Catalog Object
Set oCatalog = CreateObject("ADOX.Catalog")

' Open Access MDB
oCatalog.ActiveConnection = sConnString

' Enumerate tables in catalog
For Each oTable In oCatalog.Tables
' Filter on user tables only
If oTable.Type = "TABLE" Then
MsgBox "Table Name: " & oTable.Name
End If
Next

Set oTable = Nothing
Set oCatalog = Nothing
Set oConn = Nothing
Set oPkg = Nothing

Main = DTSTaskExecResult_Success
End Function
--
Darren Green (SQL Server MVP)
DTS - http://www.sqldts.com




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.