Solved

Display ValidationText from a MS Access database with Delphi 5

Posted on 2004-08-27
8
198 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
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 125 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

Industry Leaders: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Working this component WebCopy with proxy, help 3 100
Dev Express grid collapse 2 47
Convert MS Word document to a PDF file 9 114
DBCtrlGrid, Delphi, Scroll 8 57
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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

735 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