Solved

Display ValidationText from a MS Access database with Delphi 5

Posted on 2004-08-27
8
192 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
Comment Utility
try the
ConstraintErrorMessage-property

just a guess

meikl ;-)
0
 
LVL 1

Expert Comment

by:TomBig
Comment Utility
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
Comment Utility
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
 
LVL 1

Expert Comment

by:TomBig
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 1

Expert Comment

by:TomBig
Comment Utility
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
Comment Utility
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
Comment Utility
Thank you very much!

 - Mats Magnem
0
 
LVL 1

Expert Comment

by:TomBig
Comment Utility
you're welcome ;)
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

763 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now