Solved

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

Posted on 2001-08-17
12
481 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
Comment Utility
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
Comment Utility
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
Comment Utility
{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
 
LVL 10

Expert Comment

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

Good work shagrouni
0
 
LVL 1

Author Comment

by:DOOM_DAEMON
Comment Utility
  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
Comment Utility
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 10

Expert Comment

by:Jacco
Comment Utility
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
Comment Utility
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
Comment Utility
>>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
Comment Utility
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
Comment Utility
You help me out...Here come what you deserve as a real experts...guy
0
 

Expert Comment

by:Shagrouni
Comment Utility
:)
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now