Link to home
Start Free TrialLog in
Avatar of theHollow
theHollowFlag for Norway

asked on

Display ValidationText from a MS Access database with Delphi 5

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.
Avatar of kretzschmar
kretzschmar
Flag of Germany image

try the
ConstraintErrorMessage-property

just a guess

meikl ;-)
Avatar of TomBig
TomBig

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
Avatar of theHollow

ASKER

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
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
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.

ASKER CERTIFIED SOLUTION
Avatar of TomBig
TomBig

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you very much!

 - Mats Magnem
you're welcome ;)