MyDAC 4.X : TMyquery.Options.Requiredfields and AutoInc type fields

MyDAC 4.X : TMyquery.Options.Requiredfields and AutoInc type fields

Postby swierzbicki » Mon 05 Sep 2005 13:52

Hi,

Is there a way to disable the Required fields option with the AutoInc type fields ?

Create a table with an autoinc field (+ other test fields set to NOT NULL).
Build a delphi project with MyDAC 4.x.
Set the TMyquery.Options.Requiredfields to TRUE
Add a grid, navigator bar... Compile and run.

Insert a new record, fill all fields (except the Autoinc field).
Post : exception is raized : field 'My AutoInc field' must be filled
swierzbicki
 
Posts: 451
Joined: Wed 19 Jan 2005 09:59

Postby Ikar » Tue 06 Sep 2005 07:52

Yes, just add to MyQuery.AfterOpen event handler something like this

Code: Select all
  for i := 0 to DataSet.Fields.Count - 1 do
    if DataSet.Fields[i].AutoGenerateValue = arAutoInc then
      DataSet.Fields[i].Required := False;
Ikar
 
Posts: 1693
Joined: Thu 28 Oct 2004 13:56


Return to MySQL Data Access Components