• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 537
  • Last Modified:

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

       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
DOOM_DAEMON
Asked:
DOOM_DAEMON
  • 4
  • 3
  • 2
  • +2
1 Solution
 
JaccoCommented:
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
 
CrazyOneCommented:
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
 
ShagrouniCommented:
{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
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
JaccoCommented:
I saw those properties but didn't get them to work!

Good work shagrouni
0
 
DOOM_DAEMONAuthor Commented:
  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
 
JaccoCommented:
0
 
JaccoCommented:
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
 
CrazyOneCommented:
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
 
intheCommented:
>>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
 
DOOM_DAEMONAuthor Commented:
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
 
DOOM_DAEMONAuthor Commented:
You help me out...Here come what you deserve as a real experts...guy
0
 
ShagrouniCommented:
:)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

  • 4
  • 3
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now