Bug of FieldsOrigin with ReadOnly DataSet

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
TinTin
Posts: 46
Joined: Sat 30 May 2009 14:09

Bug of FieldsOrigin with ReadOnly DataSet

Post by TinTin » Mon 05 Nov 2012 12:40

Query1.Close;
Query1.ReadOnly := True;
Query1.Options.FieldsOrigin := True;
// join more tables,Such as:
Query1.Sql.text := 'SELECT CODE,A.NAME,SEX,BIRTHDAY,C.NAME as '+ 'GR_NAME,Mobile,TASTES,JOIN_TIME,PREPAID_AMT,B.CONSUME_AMT,MB_STATE '+
'FROM MB_MEMBER A LEFT JOIN MB_CONSUME B '+
'ON A.ID=B.ID left join MB_GRADE C '+
'ON A.GRADE_ID=C.ID ';
Query1.Open;

for i := 0 to Query1.FieldCount - 1 do
begin
listbox1.AddItem(Query1.Fields.Origin+':'+Query1.Fields.FieldName,nil);
end;

IF Query1.ReadOnly is False,FieldsOrigin is correctly
But Query1.ReadOnly is True,FieldsOrigin is ".FieldName",it have not Origin Table Name!

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Bug of FieldsOrigin with ReadOnly DataSet

Post by AlexP » Mon 05 Nov 2012 13:33

Hello,

We cannot reproduce the problem: independently on the ReadOnly option value, field names are displayed correctly. Please specify the DB you are using and the versions of UniDAC and IDE.

TinTin
Posts: 46
Joined: Sat 30 May 2009 14:09

Re: Bug of FieldsOrigin with ReadOnly DataSet

Post by TinTin » Mon 05 Nov 2012 13:54

with open join tables,
if readonly is false,
TField.Origin names is TableName+ "."+FiedName,
if readonly is True,
TField.Origin names is "."+FiedName.

I am using delphi xe + unidac 4.5.9 + sql server 2000!

i want to upload a image for you,but the forum can not support it!

TinTin
Posts: 46
Joined: Sat 30 May 2009 14:09

Re: Bug of FieldsOrigin with ReadOnly DataSet

Post by TinTin » Mon 05 Nov 2012 13:57

i run and trace into unidac code:

procedure TDADataSetService.SetFieldOrigin(Field: TField; FieldDesc: TCRFieldDesc);
var
TblName: _string;
begin
if FieldDesc.TableInfo <> nil then begin
TblName := FieldDesc.TableInfo.TableName;
TblName := FDataSet.SQLInfo.NormalizeName(TblName, False, True);
Field.Origin := TblName + '.' + FieldDesc.ActualName;
end
else
Field.Origin := FieldDesc.ActualName;
end;

TblName is null,so Field.Origin := '.' + FieldDesc.ActualName;

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Bug of FieldsOrigin with ReadOnly DataSet

Post by AlexP » Tue 06 Nov 2012 09:10

Hello,

When the ReadOnly property of DataSet is set up, MS SQL Server returns the metadata of a table, therefore the Origin property returns only the "local" field name, i.e. if a field has a Field1 as MyField alias, the alias will be in the Origin property instead of the original field name. This is due to the behaviour of the MS SQL Server, and we cannot chane it. To retrieve the full information with Origin, you should set the ReadOnly property to True.

TinTin
Posts: 46
Joined: Sat 30 May 2009 14:09

Re: Bug of FieldsOrigin with ReadOnly DataSet

Post by TinTin » Tue 06 Nov 2012 13:04

To retrieve the full information with Origin, you should set the ReadOnly property to True.
======
??
I test it,Must set TUniQuery.ReadOnly is False!

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Bug of FieldsOrigin with ReadOnly DataSet

Post by AlexP » Tue 06 Nov 2012 13:10

Hello,

Sorry for my misprints, you should set the ReadOnly property to FALSE

TinTin
Posts: 46
Joined: Sat 30 May 2009 14:09

Re: Bug of FieldsOrigin with ReadOnly DataSet

Post by TinTin » Tue 06 Nov 2012 13:23

AlexP,Thanks you very much!
I have to Query Data First,and then Set Readonly is true!

Post Reply