473,387 Members | 3,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

how to get db tables?

Ciary
247 Expert 100+
hi all, seems like i'm stuck with another problem. in my website i'm using a access database. to do this, i used odbc with a connection string. what i want to do now is print a list of all tables in this connection. does anyone know how this can be done?


the code below is what i have so far. it returns the fields of 1 table:
Expand|Select|Wrap|Line Numbers
  1. db_connection = new COM("ADODB.Connection", NULL, 1251);
  2. $db_connstr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=".$path."Persist Security Info=False;";
  3.  
  4. $db_connection->open($db_connstr);
  5. $query = "SELECT * FROM goo";
  6. $rs = $db_connection->execute($query);
  7. $rs_fld0 = $rs->Fields(0);
  8. $rs_fld1 = $rs->Fields(1);
  9. $rs_fld2 = $rs->Fields(2);
  10.  
  11. $fields = array();
  12. for( $x = 0; $x < $rs->Fields->Count; $x++ ){
  13.     $fields[] = $rs->Fields[$x]->Name;
  14. }
  15.  
  16.  
  17. $rs->Close();
  18. $db_connection->Close(); 
  19. ?>
Apr 17 '09 #1
3 2400
Markus
6,050 Expert 4TB
This thread may be of some help to you.

I'm not experienced with ODBC, though.

Let me know how you get on.

Mark.
Apr 17 '09 #2
Ciary
247 Expert 100+
not really :(
but i found another way.
now, i'm reading the system tables of access. i dont know if you're familiar with access but normally on the left side of the screen there is a navigation pane. the contents of this pane are stored in the table: MSysNavPaneObjectIDs. if you read this one and filter its contents, you get your own tables. you need to filter on type (1 for tables) and filter the system tables (those are always the same so i've put them in an array for those who want to do the same.

Expand|Select|Wrap|Line Numbers
  1. $notMyTables = array(MSysDb, MSysObjects, MSysACEs, MSysQueries, MSysRelationships, MSysComplexColumns, MSysComplexType_UnsignedByte, MSysComplexType_Short, MSysComplexType_Long, MSysComplexType_IEEESingle, MSysComplexType_IEEEDouble, MSysComplexType_GUID, MSysComplexType_Decimal, MSysComplexType_Text, MSysComplexType_Attachment, MSysAccessStorage, MSysAccessXML, MSysIMEXColumns, MSysIMEXSpecs, MSysNavPaneGroupCategories, MSysNavPaneGroups, MSysNavPaneGroupToObjects, MSysNavPaneObjectIDs);
tnx anyway Marcus
Apr 20 '09 #3
Ciary
247 Expert 100+
one more thing (for future users), mdb is slightly different then accdb. first you need to add "MSysAccessObjects, " to your array.

second, you need to change the permissions of the MSysNavPaneObjectIDs table. it hasn't any which will make it unable to be read outside access.

if anyone needs the full code, just ask.
Apr 20 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

44
by: Mariusz Jedrzejewski | last post by:
Hi, I'll be very grateful if somebody can explain me why my Opera 7.23 (runing under linux) doesn't show me inner tables. Using below code I can see only "inner table 1". There is no problem with...
3
by: Random Person | last post by:
Does anyone know how to use VBA to relink tables between two MS Access databases? We have two databases, one with VBA code and the other with data tables. The tables are referenced by linked...
11
by: dskillingstad | last post by:
I've been struggling with this problem for some time and have tried multiple solutions with no luck. Let me start with, I'm a novice at Access and I'm not looking for someones help to design my...
2
by: Jill Elaine | last post by:
I am building an Access 2002 frontend with linked tables to an encrypted Paradox 7 database. When I first create these linked tables, I'm asked for the password to the encrypted Paradox database,...
1
by: Shelby | last post by:
Problem: My company generates its own data export from a propietary database. These (free) tables can be read in C#.NET using a Visual FoxPro driver (vfpoledb). I can read each of the six tables...
59
by: phil-news-nospam | last post by:
In followups by Brian O'Connor (ironcorona) to other posts, he repeats the idea that using tables in CSS is not something that should be done because IE doesn't support it. Of course I'm not happy...
5
by: rdemyan via AccessMonster.com | last post by:
I have a need to add another field to all of my tables (over 150). Not data, but an actual field. Can I code this somehow. So the code presumabley would loop through all the tables, open each...
4
by: db2admin | last post by:
Hello, I want to plan rearranging tables in our database according to business areas. say all tables in business area A will be in seperate tablespace or tablespaces. I am planning to monitor...
25
by: bubbles | last post by:
Using Access 2003 front-end, with SQL Server 2005 backend. I need to make the front-end application automatically refresh the linked SQL Server tables. New tables will be added dynamically in...
11
by: shriil | last post by:
Hi I have this database that calculates and stores the incentive amount earned by employees of a particular department. Each record is entered by entering the Date, Shift (morn, eve, or night)...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.