Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Display ValidationText from a MS Access database with Delphi 5

Posted on 2004-08-27
8
Medium Priority
?
202 Views
Last Modified: 2010-04-05
Hi there
I'm trying to display a ValidationText from a MS Access database with Delphi 5. But I don't seem to make it work.

I have a TADOConnection to the database. I also have a TADODataset which I can access my tables with. But I can only get Name, Precision, Required, Size etc from the FieldDef. I am interested in showing (and altering) the ValidationText. But that property is not there.

I tried:
  myDataSet.FieldDefs[0].Name  (no ValidationText property)

I have done it in VB, where the code is like following:
  Dim tmpTbl As TableDef
  Set tmpTbl = tmpBas.TableDefs!my_table
  tmpTbl.Fields("field1").ValidationText = "My validation text"

What do I do wrong? Is it even possible?

 - Mats Magnem
Delphi...yeah! Still learning.
0
Comment
Question by:theHollow
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
8 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 11912747
try the
ConstraintErrorMessage-property

just a guess

meikl ;-)
0
 
LVL 1

Expert Comment

by:TomBig
ID: 11912853
hi mats

you're using a TADOConnection (ADO!) but your vb example code contains TableDef (DAO!). In DAO you had the ValidationText on the Field Object, but you dont in ADO. This is not surprising, as this seems to be an Access Feature and ADO is designed for much more general use.
Maybe you are lucky and find the ValidationText on the Column (ADO correspondence to a TableDef Field) Objects Properties Collection.

cheers

TomBIG
0
 
LVL 4

Author Comment

by:theHollow
ID: 11912860
Nope. That didn't seem to work. I only found that property under Fields[], but something tells me that I have to get it from a FieldDef or a TableDef...somehow. I dunno.

 - Mats Magnem
Still clueless
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Expert Comment

by:TomBig
ID: 11912925
mats,

believe me. in ado there is no such thing as a TableDef. you have a Table class instead. ValidationText really definitely looks provider specific to me, so you must search where provider specific data gets into ado. that is at the properties collections of the various ado classes.

cheers
0
 
LVL 1

Expert Comment

by:TomBig
ID: 11913168
ok. i looked it up. with the Microsoft.Jet.OLEDB.4.0 provider the navigation to the ValidationText goes like this:

Catalog.Tables(<TableName>).Columns(<ColumnName>).Properties("Jet OLEDB:Column Validation Text").Value

this property is read/write.

hope this helpeed.

0
 
LVL 1

Accepted Solution

by:
TomBig earned 500 total points
ID: 11913526
delphi source could look something like this:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls,ComObj,ADODB_TLB,ADOX_TLB;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  fADOConnection: _Connection;
  fADOCatalog: _Catalog;
begin

  fADOConnection:=CreateOLEObject('ADODB.Connection') As _Connection;
  fADOCatalog:=CreateOLEObject('ADOX.Catalog') As _Catalog;

  fADOConnection.Open('Data Source = ''test.mdb''; Provider=Microsoft.Jet.OLEDB.4.0;','','',0);
  fADOCatalog._Set_ActiveConnection(fADOConnection);
  Label1.Caption:=fADOCatalog.Tables.Item['Test'].Columns.Item['Test'].Properties.Item['Jet OLEDB:Column Validation Text'].Value;
end;

end.

cheers
0
 
LVL 4

Author Comment

by:theHollow
ID: 11913580
Thank you very much!

 - Mats Magnem
0
 
LVL 1

Expert Comment

by:TomBig
ID: 11913641
you're welcome ;)
0

Featured Post

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

730 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