Solved

TADOTable  Field.Required property

Posted on 2004-04-15
7
561 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
[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
  • 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
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 

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

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month7 days, left to enroll

622 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