What is the equivalent object for ADOdataset.RecordSet ???
-
Tugrul Tamturk
- Posts: 32
- Joined: Mon 25 Aug 2008 18:28
What is the equivalent object for ADOdataset.RecordSet ???
Hi,
I have a old code like this:
for i := 0 to ADODataSet.Recordset.Fields.Count - 1 do begin
TableName := VarToStr(ADODataSet.Recordset.Fields.Properties.Item[1].Value);
FieldName := VarToStr(ADODataSet.Recordset.Fields.Properties.Item[0].Value);
//...
end;
I could get easly TableName of a field in Query (more than one table joined) using RecordSet object.
How can I use recordset in UniDac? Or How can I get Table name of a field from a TUniQuery object.
Unidac 3.00.0.10 for Delphi 7
MsSQL 2005 Standart Edition
Best Regards
Tugrul
I have a old code like this:
for i := 0 to ADODataSet.Recordset.Fields.Count - 1 do begin
TableName := VarToStr(ADODataSet.Recordset.Fields.Properties.Item[1].Value);
FieldName := VarToStr(ADODataSet.Recordset.Fields.Properties.Item[0].Value);
//...
end;
I could get easly TableName of a field in Query (more than one table joined) using RecordSet object.
How can I use recordset in UniDac? Or How can I get Table name of a field from a TUniQuery object.
Unidac 3.00.0.10 for Delphi 7
MsSQL 2005 Standart Edition
Best Regards
Tugrul
-
AndreyZ
Hello,
You should use this code:
You should use this code:
Code: Select all
for i := 0 to UniQuery.Fields.Count - 1 do begin
TableName := TCRFieldDesc(UniQuery.GetFieldDesc(UniQuery.Fields[i].FieldNo)).TableInfo.TableName;
FieldName := UniQuery.Fields[i].FieldName;
end;-
Tugrul Tamturk
- Posts: 32
- Joined: Mon 25 Aug 2008 18:28
-
Tugrul Tamturk
- Posts: 32
- Joined: Mon 25 Aug 2008 18:28
-
Tugrul Tamturk
- Posts: 32
- Joined: Mon 25 Aug 2008 18:28
-
AndreyZ
Hello,
The TableInfo.TableAlias property is filled when you are using aliases in the query. For example, if you execute the "select * from testtbl test" statement, the TableInfo.TableName property will contain the "testtbl" string, and the TableInfo.TableAlias property will contain the "test" string.
Please specify the exact SQL statement that doesn't conform to this rule.
The TableInfo.TableAlias property is filled when you are using aliases in the query. For example, if you execute the "select * from testtbl test" statement, the TableInfo.TableName property will contain the "testtbl" string, and the TableInfo.TableAlias property will contain the "test" string.
Please specify the exact SQL statement that doesn't conform to this rule.
-
Tugrul Tamturk
- Posts: 32
- Joined: Mon 25 Aug 2008 18:28
Hi Andrey,
I found a bug about TableInfo.TableAlias. When same join table exist more than one time in query. TableAlias brings always last join table's alias.
Unidac 3.70.0.18
Delphi 2007
MsSql2008R2
Uniquery1.Sql.Text :=
SELECT R1.NAME AS ARACI, R2.NAME AS TEMSICLI, S.SIPARISID FROM SIPARIS S
LEFT JOIN RESOURCES R1 ON R1.RESOURCESID = S.A_RESOURCEID
LEFT JOIN RESOURCES R2 ON R2.RESOURCESID = S.B_RESOURCEID
FD := TCRFieldDesc(UniQuery1.GetFieldDesc(UniQuery1.Fields[0].FieldNo));
T1 := FD.TableInfo.TableAlias; //>> R2 !Wrong! must be R1
FD := TCRFieldDesc(UniQuery1.GetFieldDesc(UniQuery1.Fields[1].FieldNo));
T2 := FD.TableInfo.TableAlias;// >> R2 !Correct!
I found a bug about TableInfo.TableAlias. When same join table exist more than one time in query. TableAlias brings always last join table's alias.
Unidac 3.70.0.18
Delphi 2007
MsSql2008R2
Uniquery1.Sql.Text :=
SELECT R1.NAME AS ARACI, R2.NAME AS TEMSICLI, S.SIPARISID FROM SIPARIS S
LEFT JOIN RESOURCES R1 ON R1.RESOURCESID = S.A_RESOURCEID
LEFT JOIN RESOURCES R2 ON R2.RESOURCESID = S.B_RESOURCEID
FD := TCRFieldDesc(UniQuery1.GetFieldDesc(UniQuery1.Fields[0].FieldNo));
T1 := FD.TableInfo.TableAlias; //>> R2 !Wrong! must be R1
FD := TCRFieldDesc(UniQuery1.GetFieldDesc(UniQuery1.Fields[1].FieldNo));
T2 := FD.TableInfo.TableAlias;// >> R2 !Correct!
-
AndreyZ
-
AndreyZ