Bug of FieldsOrigin with ReadOnly DataSet
Bug of FieldsOrigin with ReadOnly DataSet
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!
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!
Re: Bug of FieldsOrigin with ReadOnly DataSet
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.
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.
Re: Bug of FieldsOrigin with ReadOnly DataSet
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!
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!
Re: Bug of FieldsOrigin with ReadOnly DataSet
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;
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;
Re: Bug of FieldsOrigin with ReadOnly DataSet
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.
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.
Re: Bug of FieldsOrigin with ReadOnly DataSet
To retrieve the full information with Origin, you should set the ReadOnly property to True.
======
??
I test it,Must set TUniQuery.ReadOnly is False!
======
??
I test it,Must set TUniQuery.ReadOnly is False!
Re: Bug of FieldsOrigin with ReadOnly DataSet
Hello,
Sorry for my misprints, you should set the ReadOnly property to FALSE
Sorry for my misprints, you should set the ReadOnly property to FALSE
Re: Bug of FieldsOrigin with ReadOnly DataSet
AlexP,Thanks you very much!
I have to Query Data First,and then Set Readonly is true!
I have to Query Data First,and then Set Readonly is true!