_Not so easy ADO question...

_Not so easy ADO question...

serge
Advocate Advocate
253 Views
5 Replies
Message 1 of 6

_Not so easy ADO question...

serge
Advocate
Advocate
I can connect to an ACCESS-file from within ACAD without any problem ... I do use ADO for this with a connection string and a SQL-statement for accessing a Table ... Here's my question: Has anybody has a programm-example how to check if a certain table exist in de mdb-file, if not how to copy another existing Table in a new one ... Thanks for any ideas ... SMD
DEVIDTS Serge, CAD Consultant
http://www.CADdICT.be
0 Likes
254 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
To get the tables in the database, use the OpenSchema method of the
Connection object with the adSchemTables parameter. See
<>.

How to proceed if the table you want isn't there depends on what you
want to do with that table. Probably the easiest thing to do is to
create a view (if the view isn't there already .. use the OpenSchema
method with the adSchemaViews parameter). (Access calls views
"queries"). Just execute the SQL statement "create view
as select * from ". Then the view can be treated as if it
were a table. Changes to the records in the view will appear in the
underlying table.

--
jrf
Member of the Autodesk Discussion Forum Moderator Program
Please do not email questions unless you wish to hire my services

In article , Smd wrote:
> I can connect to an ACCESS-file from within ACAD without any
problem
> ... I do use ADO for this with a connection string and a
> SQL-statement for accessing a Table ... Here's my question: Has
> anybody has a programm-example how to check if a certain table
exist
> in de mdb-file, if not how to copy another existing Table in a new
> one ... Thanks for any ideas ... SMD
>
0 Likes
Message 3 of 6

Anonymous
Not applicable
In article , Jon Fleming wrote:
> use the OpenSchema method of the
> Connection object with the adSchemTables parameter.

Whoops, adSchemaTables parameter.

--
jrf
Member of the Autodesk Discussion Forum Moderator Program
Please do not email questions unless you wish to hire my services
0 Likes
Message 4 of 6

serge
Advocate
Advocate
Hi Jon ...
Iterating through the Tables is no problem anymore, but copying a existing table does NOT work with a "CREATE VIEW..."-SQL, since ACCESS is not supporting this SQL-statement ... I wrote In the access-file a VBA-macro to copy a existing table, this works well, how can I trigger this Macro from within ACAD-VBA ? ... Any other solutions to copy an existing table in an Access file are also aprreciated ... Thanks, SMD ...
DEVIDTS Serge, CAD Consultant
http://www.CADdICT.be
0 Likes
Message 5 of 6

Anonymous
Not applicable
Arggh! Bill strikes again! How can they not support "create view
.."?

I don't know of any way to trigger the VBA macro; it's out-of-scope
for AutoCAD VBA and the driver that interfaces with the database.

I know that Access supports "create table ..." (and "drop table ...");
you could create the table and then do "update ,
set . = ., . =
., ...".

If you know the name of the table that contains the information you
need, why do you insist on accessing that information under another
table name?

--
jrf
Member of the Autodesk Discussion Forum Moderator Program
Please do not email questions unless you wish to hire my services

In article , Smd wrote:
> Hi Jon ...
> Iterating through the Tables is no problem anymore, but
> copying a existing table does NOT work with a "CREATE VIEW..."-SQL,
> since ACCESS is not supporting this SQL-statement ... I wrote In the
> access-file a VBA-macro to copy a existing table, this works well,
> how can I trigger this Macro from within ACAD-VBA ? ... Any other
> solutions to copy an existing table in an Access file are also
> aprreciated ... Thanks, SMD ...
>
0 Likes
Message 6 of 6

Anonymous
Not applicable
As Jon suggested you can use ADO to create a table as needed, I don't know
off hand if ADO supports any method for copying an existing table. If you do
write an Access macro then you can run it from your VB/VBA routine by
setting a reference to the Microsoft Access type library in your project
then use the following...

Private Sub RunProc()
Application.Run "YourAccessMacro"
End Sub


Obviously Application must be a valid reference to the Access Application
object and "YourAccessMacro" (as a string) must be the name of a public sub
defined in the current access database.

Regards,
Jacob Dinardi


"smd" wrote in message
news:f0c8649.2@WebX.maYIadrTaRb...
> Hi Jon ...
> Iterating through the Tables is no problem anymore, but copying a existing
table does NOT work with a "CREATE VIEW..."-SQL, since ACCESS is not
supporting this SQL-statement ... I wrote In the access-file a VBA-macro to
copy a existing table, this works well, how can I trigger this Macro from
within ACAD-VBA ? ... Any other solutions to copy an existing table in an
Access file are also aprreciated ... Thanks, SMD ...
>
0 Likes