Solved

TADOTable  Field.Required property

Posted on 2004-04-15
7
552 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
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…

821 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