Solved

TADOTable  Field.Required property

Posted on 2004-04-15
7
548 Views
Last Modified: 2013-11-23
When TADOTable object connected to SQL Database table. I noticed that the Field.Required and FieldDef.Required property always returns False, even though the underlying Table has field which is non Nullable.

Is it because of the MDAC version or SQL server version conflict ? I search every where on the web but could not find any one mentioned about having this problem.

I am using XP machine to connect to SQL Sever 2000 which is running in window 2000 server.

Your help will be very much appreciated.

Cheers,

nctran
0
Comment
Question by:nctran
  • 3
  • 2
  • 2
7 Comments
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 10831243

   Delphi help says :

If a field is created with the Fields editor, then this property is set based on the underlying table. Applications that set Required to True for fields that must have values (for example, a password or part number), but for which the underlying table does not require the field, must write an OnValidate event handler to enforce the property.
0
 
LVL 22

Accepted Solution

by:
Mohammed Nasman earned 300 total points
ID: 10831757
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 10831777

   whenever possible - use direct access components :P)

   http://crlab.com/sdac/

   I am using them and everything is OK :)))
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:nctran
ID: 10831789

SQL database table has specified the field is required (non Nullable). But when loaded into TADOTable the field.Required property is always return false.
 
  any ideas ?

Best Regards
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 10831795
Hello

  Here's a better way, without modifying Delphi sources

procedure TForm1.Button1Click(Sender: TObject);
var
  ReqField : Integer;
const
  adFldIsNullable = $00000020;
begin
  if (AdoTable1.Recordset.Fields[1].attributes and adFldIsNullable) = 0 then
    ShowMessage(AdoTable1.Recordset.Fields[1].Name + ' is Required Field')
  else
    ShowMessage(AdoTable1.Recordset.Fields[1].Name + ' not Required Field')

end;

Regards,
Mohammed
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 10831808

    Set Debug DCU in Project / Options / Compiler / Debugging and step inside the ado units to see why it fails ...
0
 

Author Comment

by:nctran
ID: 10838331
Thanks Mohammed,
I knew it was a bug in ADO express but not quite sure where is a good place to fix it. Because I Trace through the code and found that the attributes never get check again adFldNullable.

It seems to work for SQL database .But I don't know if there is any problem when connected TADOTable object to any other databases and I hope not.

 I prefer to change it in the ADODB because It saves me to go everywhere in my code to change Field.Required to Recordset.Field[i].Attributes and adFldIsNullable = 0

So I  will accept your comment.

Thank you.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

914 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

16 Experts available now in Live!

Get 1:1 Help Now