Click here to Skip to main content
Click here to Skip to main content

Database info tool

, 26 Oct 2000
Rate this:
Please Sign up or sign in to vote.
Explore the structure of tables (and views)
<!-- Download Links -->
  • Download source files - 19 Kb
  • <!-- Article image -->

    Sample Image - DBInfo.gif

    What is this?

    This useful tool solves me a big problem: the ability to see what's the structure of a table in a database. Using this software you can read structure of tables, views and system tables. You can also list that structure into a .TXT file or print directly for a convenient use.

    How to use

    Since the access to the database is done via ODBC, you can read every database having only the right ODBC drivers.

    Normally each database you can access, has it's own DSN (data source name) identified by an unique name: clicking on button Select DB you can see the list of defined DSN, select the one you want inspect and read all tables' structure.

    If you enable Views and System Tables, you can see all views and system tables. Some databases (as ACCESS 97) don't allow you to read system tables. Select the table (or view) in the combo and see what's inside. You don't have the specific DSN for your database? Don't worry: select, from the DSN list, the DSN of the database engine it will automatically ask what database (often a file) to handle, and DBInfo will do the rest.

    Known Bugs

    I know that the code is NOT a valid example for beginner programmers... as you can see, minimal exception handling, no UNICODE support, and so on. But it's intended for programmers only; a crash isn't a problem in that case.

    You can find a bug that doesn't represent a real problem: if the table has a space (or minus sign) in its name, I enclose the table name between two brackets; some database engines doesn't like this. In that case a message will inform you about this problem.

    This is the code I use:

    // add [ & ] if name contains spaces or others chars
    if( sBuffer.Find(' ') != -1 ||
        sBuffer.Find('-') != -1 ) {
        sSQL  = "SELECT * FROM [";
        sSQL += sBuffer;
        sSQL += "]";
    } else {
        sSQL  = "SELECT * FROM ";
        sSQL += sBuffer;
    }
    

    where sBuffer contains the name of the table (or view).

    Special Thanks

    This tool was wrote after I did learn valid programming technique reading great code from George Poulose [Interactive SQL Tool (using ODBC)], Chris Maunder [Printing without the Document/View framework] and Richard Stringer [Printing Class Library] jobs.
    Without their articles I would be unable to create this tool. Thanks again guys!

    That's all folks!

    If you have some minutes to waste, visit my homepage.

    License

    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    A list of licenses authors might use can be found here

    Share

    About the Author

    Massimo Colurcio
    Software Developer (Senior)
    Italy Italy
    Too lazy to write something about me...

    Comments and Discussions

     
    QuestionWhy... PinmemberLowFly10-Jan-12 20:19 
    Generalsql error Pinmemberrasha7615-Sep-04 21:36 
    GeneralSQLBrowseConnection PinmemberSimone Giannecchini16-Dec-01 1:57 
    QuestionExcel tables? PinmemberAmmar17-Apr-01 2:16 
    AnswerRe: Excel tables? PinmemberMassimo Colurcio17-Apr-01 7:54 

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

    | Advertise | Privacy | Mobile
    Web02 | 2.8.141022.2 | Last Updated 27 Oct 2000
    Article Copyright 2000 by Massimo Colurcio
    Everything else Copyright © CodeProject, 1999-2014
    Terms of Service
    Layout: fixed | fluid