Solved

Retrieving MDB Table, Field Description, How? Not Table Name, Field Name. Help me out, please...

Posted on 2001-08-17
12
497 Views
Last Modified: 2010-04-06
       I've post this message once but it seemed to me none of real experts out there can neither figure it out nor interested in my point So I decided to repost it again with more point back...only if it's done. Here' s my question.
        I've been wondering how to retrieve Description of MDB Database table and its correspodging
fields Description...Please make sure you understand me before have your comment posted. I mean Table Description, Field Description. A Description you added when you Create Table and it's field. **** Not A Table Name, or Field Name***** Just it's description...
        For example, I created database, say mdb database, using Microsoft Access. I then created Table
name "FirstTable" and put right click on it and type in "This is my first Table " as it's description.
As you can see, it's description can be viewed in Detail Mode to see what description it has. I then
create fields, just 2 fields named "fldFirst" as Text field and Type in "This is First Field" as it's
description...The same way I did to second field named "fldSecond" with corresponding Description "This
is Second Field". Finally I saved it.
        By now, I need fully coded written in Delphi to retrieve Table Description, and First, Second
Field Descripion. Please explain me in detail if it needed.
        Just real programmer out there can do it, I know...Do me a favor, I'll give you back some point...please.  
Question History
0
Comment
Question by:DOOM_DAEMON
  • 4
  • 3
  • 2
  • +2
12 Comments
 
LVL 10

Expert Comment

by:Jacco
ID: 6402999
I think the only way is interpreting the MDB file. (I have view the MDB with notepad and can see that the descriptions are in there).

I have tried the following:

ADO: does not have an interface to the descriptions
DAO: does not have an interface to the descriptions
Access objects: do not have an interface for it either

So I think the only program that will get the description from the file is MS Access itself. Maybe they don't want anybody writing a better interface for MDB files....

Regards and good luck Jacco
0
 
LVL 44

Expert Comment

by:CrazyOne
ID: 6409959
Well I figured if there was an interface availble for this it would be in VB since Access is VB's native database. No such luck though. There does not appear to be any direct way to retrieve this info. Weird to say the least but MS does have a habit of not making certain things available to the developer.
0
 

Accepted Solution

by:
Shagrouni earned 300 total points
ID: 6420627
{uses ComObj}

procedure TForm1.Button1Click(Sender: TObject);
var
  Obj, db, tb: variant;
  dbName, tbName, s: string;
  i: integer;
begin
  dbName := 'MyDb.mdb';
  tbName := 'MyTb';
  Obj := CreateOleObject('DAO.DBEngine.36');   // or 'DAO.DBEngine.35'
  db := Obj.OpenDatabase(dbName, false, false, '');
  tb := db.OpenRecordSet(tbName, 1);  {dbOpenTable}
  s := tb.Name + ' : ' + tb.Properties['Description'].Value;
  Memo1.Lines.Add (s);

  for i := 0 to tb.Fields.Count -1 do
  begin
    s := tb.Fields[i].Name + ' : ' +
         tb.Fields[i].Properties['Caption'].Value + ' : ' +
         // error if there is no caption
         tb.Fields[i].Properties['Description'].Value;
         // error if there is no Description
    Memo1.Lines.Add (s);
  end;
  tb.Close;
  db.Close;

  {
  // to get all properts availbe
  for i := 0 to tb.Fields[1].Properties.Count-1 do
  begin
    s := VarToStr(tb.Fields[1].Properties[i].Name) + ' : ' ;
    s := s + VarToStr(tb.Fields[1].Properties[i].Type) + ' : ' ;
    try
      s := s + VarToStr(tb.Fields[1].Properties[i].Value);
    except
      s := s + '<??>'
    end;
    Memo1.Lines.Add (s);
  end;
  }
end;
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 10

Expert Comment

by:Jacco
ID: 6420792
I saw those properties but didn't get them to work!

Good work shagrouni
0
 
LVL 1

Author Comment

by:DOOM_DAEMON
ID: 6424627
  I don't try your code posted here yet. Anyway, anyone tried it should tell me how well it work with Delphi. I don't agree with you, Jacco. Cause I think, personally, MDB has been widely used throughout this world. One thing they must provide is a compatible between programming platform. Not just for Microsoft....
   So if it work, please ya all do me a favor inform me if previous code work or not...So I'll give Shangrouni some points for his mercy on me....
0
 
LVL 10

Expert Comment

by:Jacco
ID: 6424650
0
 
LVL 10

Expert Comment

by:Jacco
ID: 6424652
It works. I have tried with Delphi 5 (you have to have MS Access or DAO components installed). I didn't know MDB files were supported onm other platforms than MS.

Regards Jacco
0
 
LVL 44

Expert Comment

by:CrazyOne
ID: 6424704
Hi Jacco as far as I know Access main target is Windows and I believe there is a version for Apple, definitely no versions of it are made for UNIX or Linux or BeOS, etc. Of course 32 bit versions of it will not run on Win 3.1. MS will be discontinuing support for Win95 by the end of this year so any upcoming versions of Access may not work on Win95 anymore and by mid 2003 the same will hold true for Win98 because that is the target date MS has set for discontinuing support for that OS. So in two years any software produced by MS will only be targeted for the NT OS's and ME.

Actually I think what DOOM_DAEMON was referring to was compatibility between programming languages and not OS's, which I would disagree with. MS is not under any legal obligation to make Access compatible with any language if they don't want to. It is their product and they have the same legal rights as any other developer to make their product compatible with whatever they choose to. :>)
0
 
LVL 17

Expert Comment

by:inthe
ID: 6424759
>>So in two years any software produced by MS will only be targeted for the NT OS's and ME.

interesting..maybe a good thing too,can be annoying coding for different platforms worrying about which one supports what.

DOOM_DAEMON ,
Shagrouni's code works pretty good,i like the all available properties part could be useful.
0
 
LVL 1

Author Comment

by:DOOM_DAEMON
ID: 6426271
Finally, I've tried it myself and ofcourse, as you all experts can see, it works...So thanks to ya Shagrouni'...Here I give you expertise points...You know what, You deserve it...Thank you again.
0
 
LVL 1

Author Comment

by:DOOM_DAEMON
ID: 6426275
You help me out...Here come what you deserve as a real experts...guy
0
 

Expert Comment

by:Shagrouni
ID: 6427129
:)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Run video youtube webbrowse 10 65
Base1 Encode/Decode 3 81
Sending files from  idTcpServer Socket to idTcpClient 2 44
firemonkey keyboard covers the controls 1 37
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question