Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Display ValidationText from a MS Access database with Delphi 5

Posted on 2004-08-27
8
Medium Priority
?
203 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
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Integration Management Part 2
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

916 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