Hi, I'm using 2.6.5 (fixes_2_6) now but something broke between 2.6.2 and 2.6.5 using AutoInc fields. AutoInc never worked well (at least for MSSQL) and because that I have my own "Query" [1] that implements AutoInc values very well.
I override the ApplyRecUpdate method from TSQLQuery and update the AutoInc field getting the value in DB using FLib.GetLastAutoIncValue method that, for MSSQL, I use "select scope_identity() as id" (see code below) The problem is to use Field.SetData to put a value. If the field is AutoInc it is ReadOnly too and I got a exception: Edit; Fields[I].SetData(@LastId); Post; But in 2.6.2 version it worked. I need to know the ID (identity column). So, if the behavior was changed between 2.6.5 and 2.6.2, then the AutoInc fields needs to works too, no? Now, how I can get the ID using AutoInc, please? === BEGIN CODE === procedure TghSQLdbQuery.ApplyRecUpdate(UpdateKind: TUpdateKind); var I: Integer; LastId: NativeInt; Fld: TField; begin inherited; if UpdateKind <> ukInsert then Exit; for I := 0 to Fields.Count -1 do begin Fld := Fields.Fields[I]; if Fld.IsNull and ((Fld.DataType = ftAutoInc) or (LowerCase(Fld.FieldName) = 'id') and (Fld is TNumericField)) then begin LastId := FLib.GetLastAutoIncValue; if LastId <= 0 then Exit; Edit; Fields[I].SetData(@LastId); Post; Exit; end; end; end; === END CODE === [1] https://github.com/mdbs99/Greyhound Regards, Marcos Douglas _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal