Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Browsing tables in a database

Status
Not open for further replies.

AndrewMozley

Programmer
Oct 15, 2005
621
1
18
GB

I would like to develop a utility which can offer a simple browse of the tables in a database. A grid of each table and its description would be offered. When a table is selected the user is given the chance to browse the table, possibly using one of the indexes set up for that table. This would be used by developers.

One could perhaps reading the database container as a table and extract information from there into a cursor which would act as the Recordsource for the grid. Would that be possible, and has anyone done work along these lines?

Thanks. Andrew

 
Andrew,

The ADBOBJECTS() function will give you an array containing the names of all the tables in the database. You could then present this list to the user, and have them choose the table in question. This would be easier than reading the DBC file as table (although it wouldn't show the descriptions of the tables).

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
I have a stupidly simple utility for this kind of thing - like a more modern (but largely unfinished) dbu from the
days of Clipper.


I think it needs the VFP9 runtimes to work.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are not good for you.
 
For a list of databases tables: ADBOBJECTS(laTables,"TABLE")
Yes, you might also select from the dbc used as a table.

Then simply USE some dbf and set a grid.recordsource to it.

Only developers without VFP would need such a tool and there already are several of these, eg DBF viewer 2000

Bye, Olaf.
 
I mentioned that ADBOBJECTS() doesn't give you the description of the table (which you said you wanted to show along with the table name). You can use DBGETPROP() for that - to get the Comment property.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Yes, you can get many more infos from that and of course AFIELDS, once a table is open shows more about it including rules, the called trigger (if) and field comments, etc., it's not hard to write such a tool without hacking the DBC. You can also get at procedure code with COPY PROCEDURES, but in that aspect reading from the second or third DBC record is easier than writing out a txt file and readding that back in. There is an official way to get at any info, also ATAGINFO() for infos about indexes. You just have to look around a bit in the see also sections and you learn this stuff.

Bye, Olaf.
 
Andrew,
Have you tried SuperBrowse?
It probably does all you want already, and then some.

Best Regards,
Scott
ATS, CDCE, CTIA, CTDC

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Thank you, Mike, Griff, Olaf and everyone.

Lots of useful ideas there. In fact I need to incorporate the functionality into an application mainly as an aid to myself while debugging the application; have found your suggestions most helpful.
 
I advise against this. BROWSE is filled with problems, the worst of which is you access the table directly for long periods of time. I've seen more data corruption cause by BROWSE than any other single command.

A better way is to use a grid against a read-only cursor.

Craig Berntson
.Net MVP, Author, Tech Presenter
 
Craig,

I am under the impression that Andrew is already using a grid. He didn't say he was using a Browse window. He simply said he wanted to browse the tables. I didn't take that to mean he was using a BROWSE command - nor did any of the others who replied, as far as I can see.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top