Solved

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

Posted on 2001-08-17
12
485 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Machine not responding during CopyFile() 3 88
add combobox item based on numbers 9 119
Intraweb download file link ? 1 105
Delphi and Access based Enumeration 9 44
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

937 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

10 Experts available now in Live!

Get 1:1 Help Now