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

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
swierzbicki
Posts: 451
Joined: Wed 19 Jan 2005 09:59

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

Post by 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

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by 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;

Post Reply