Problems with TMSQuery and ProviderFlags

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
MrFloyd
Posts: 4
Joined: Thu 04 Aug 2005 13:57

Problems with TMSQuery and ProviderFlags

Post by MrFloyd » Thu 04 Aug 2005 14:16

I have a problem making persistents the fields of the query.
The problem it's that the query not recognize when the field is the primary key and required.
pfInkey and required state in false (not change to true)

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

Post by Ikar » Fri 05 Aug 2005 10:02

Please specify a script to create a table and text of the query. Also specify values of TMSQuery properties.

Guest

Post by Guest » Fri 05 Aug 2005 13:24

Table
------
exec sp_addtype IDTabla, "integer", "NULL"
go

exec sp_addtype Descripcion40, "varchar(40)", "NULL"
go

exec sp_addtype CodigoHumano, "varchar(20)", "NOT NULL"
go

CREATE TABLE Areas (
Area_ID IDTabla NOT NULL,
Codigo CodigoHumano,
Descripcion Descripcion40
)
go

ALTER TABLE Areas
ADD PRIMARY KEY CLUSTERED (Area_ID ASC)
go




Query
-------
SELECT *
FROM
Areas

TMSQuery (from DFM)
PS: Today change Options.RequiredFields = True and "fields required" are retrieve but not pfInkey
-----------
object qryAreas: TMSQuery
Connection = rdmLoJackMain.dbLoJack
SQL.Strings = (
'SELECT *'
'FROM'
' Areas')
UniDirectional = True
FetchAll = False
Options.RequiredFields = True
Left = 48
Top = 16
object qryAreasArea_ID: TIntegerField
FieldName = 'Area_ID'
Origin = 'Areas.Area_ID'
end
object qryAreasCodigo: TStringField
FieldName = 'Codigo'
Origin = 'Areas.Codigo'
end
object qryAreasDescripcion: TStringField
FieldName = 'Descripcion'
Origin = 'Areas.Descripcion'
Size = 40
end
object qryAreasNotas: TStringField
FieldName = 'Notas'
Origin = 'Areas.Notas'
Size = 240
end
end


PS: Iam speak spanish only, sorry for my english :(

MrFloyd
Posts: 4
Joined: Thu 04 Aug 2005 13:57

Login Guest

Post by MrFloyd » Fri 05 Aug 2005 13:28

I request excuses, in the previous message even I not login how MrFloyd

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

Post by Ikar » Fri 05 Aug 2005 15:56

This problem happens only on creating fields at design-time. You can get a list of key fields using TCustomMSDataSet.PSGetKeyFields method.

MrFloyd
Posts: 4
Joined: Thu 04 Aug 2005 13:57

Post by MrFloyd » Mon 08 Aug 2005 13:03

I have a Provider connected to the TMSQuery component, and a TClientDataset connected to the provider.
How can I use the solution that you bring to me?, in 3 tiers...

MrFloyd
Posts: 4
Joined: Thu 04 Aug 2005 13:57

Post by MrFloyd » Tue 23 Aug 2005 15:03

Ikar wrote:This problem happens only on creating fields at design-time. You can get a list of key fields using TCustomMSDataSet.PSGetKeyFields method.
How execute PSGetKeyFields from TClientDataset? (in my application client)
i cant!

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

Post by Ikar » Fri 26 Aug 2005 07:00

Code: Select all

var
  MSQueryMIDAS: TMSQuery;
  MSProv: TDataSetProvider;
  ClientDataSet1: TClientDataSet;

  MSQueryMIDAS := TMSQuery.Create(Self);
  MSProv := TDataSetProvider.Create(Self);
  ClientDataSet1 := TClientDataSet.Create(Self);
  with MSQueryMIDAS do
  begin
    Name := 'MSQueryMIDAS';
    Connection := MSConnectionSDACTest;
  end;
  with MSProv do
  begin
    Name := 'MSProv';
    DataSet := MSQueryMIDAS;
    Options := [poAllowCommandText];
  end;
  with ClientDataSet1 do
  begin
    Name := 'ClientDataSet1';
    CommandText := 'SELECT * FROM test..AREAS';
    ProviderName := 'MSProv';
  end;

  ClientDataSet1.Open;
  Caption := BoolToStr(pfInKey in ClientDataSet1.Fields[0].ProviderFlags, True);

Post Reply