Solved

TADOTable  Field.Required property

Posted on 2004-04-15
7
547 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:
mnasman 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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

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:mnasman
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

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

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…
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…
This video discusses moving either the default database or any database to a new volume.
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…

707 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

11 Experts available now in Live!

Get 1:1 Help Now