nctran
asked on
TADOTable Field.Required property
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
whenever possible - use direct access components :P)
http://crlab.com/sdac/
I am using them and everything is OK :)))
ASKER
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
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.Field s[1].attri butes and adFldIsNullable) = 0 then
ShowMessage(AdoTable1.Reco rdset.Fiel ds[1].Name + ' is Required Field')
else
ShowMessage(AdoTable1.Reco rdset.Fiel ds[1].Name + ' not Required Field')
end;
Regards,
Mohammed
Here's a better way, without modifying Delphi sources
procedure TForm1.Button1Click(Sender
var
ReqField : Integer;
const
adFldIsNullable = $00000020;
begin
if (AdoTable1.Recordset.Field
ShowMessage(AdoTable1.Reco
else
ShowMessage(AdoTable1.Reco
end;
Regards,
Mohammed
Set Debug DCU in Project / Options / Compiler / Debugging and step inside the ado units to see why it fails ...
ASKER
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].Attribu tes and adFldIsNullable = 0
So I will accept your comment.
Thank you.
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].Attribu
So I will accept your comment.
Thank you.
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.