|
-
Sep 11th, 2001, 02:21 PM
#1
Thread Starter
Junior Member
determining tables in Access with SQL
I have quite a bit of experience writing code to deal with databases, though most of that experience deals with Sybase and Oracle. I'm trying to write a bit of code to pull values out of an Access database and place them into a Sybase database. This all has to be generic though. One of the things i want to be able to do is give a list of all the tables in a given Access database in order to match them up with tables in Sybase. All i have to do in Sybase is do a SELECT on sys.systables. Access doesn't really seem to have the same kinda thing though. Can anyone help me out here? Thanks...
-
Sep 12th, 2001, 10:20 AM
#2
Lively Member
The best method of finding the tables in an MS Access database is to cycle through the tabledefs of your database object.
So, code something a little similar to:
Dim dbMyDatabase as database
Dim defMyQueryDefs as Querydef
Set dbMyDatabase = opendatabase(<Path_to_database_including_its_name>)
for each defMyQueryDefs in dbmydatabase.querydefs
debug.print defMyQuerydefs.name
next
Or something along those lines......
-
Sep 12th, 2001, 10:51 AM
#3
Fanatic Member
The above method will work (if you use Tabledefs instead of Querydefs!) - this is OK if you can still have the ability to use DAO. ADO is a different matter (you have to utilise ADOX)
Your other optio is to goto Tool...Options in Access and under the View tab, select system objects. This gives you a bunch of tables prefixed with MSys. MSysObjects give you a list of object in the database, including tables, which can be filtered out acccording to type (last column - -i think tables are type "1", linked tables type "4" etc)
-
Sep 12th, 2001, 01:09 PM
#4
Thread Starter
Junior Member
I actually already tried to access the MSysObjects table using code, and it told me i didn't have the rights to do that. How should i connect in order to get the rights to read the rows in that table?
-
Sep 13th, 2001, 03:46 AM
#5
Fanatic Member
Yes, of course, sorry I tried it in Access using VBA. Won't work in VB
Best solution is using Tabledefs. If you are using Access 2000, you'll may want to try using ADOX.
-
Sep 13th, 2001, 04:06 AM
#6
Lively Member
Ooops sorry, I thought about it when I went home last night and realised I meant TableDefs not querydefs
-
Sep 13th, 2001, 10:26 AM
#7
Fanatic Member
Thats OK, I messed it up too...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|