What is the equivalent object for ADOdataset.RecordSet ???

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Tugrul Tamturk
Posts: 32
Joined: Mon 25 Aug 2008 18:28

What is the equivalent object for ADOdataset.RecordSet ???

Post by Tugrul Tamturk » Wed 15 Dec 2010 06:36

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

AndreyZ

Post by AndreyZ » Wed 15 Dec 2010 10:47

Hello,

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

Post by Tugrul Tamturk » Thu 16 Dec 2010 19:30

Thanks Andrey,

TCRFieldDesc declared CRAccess unit by the way..

Regards
Tugrul

AndreyZ

Post by AndreyZ » Fri 17 Dec 2010 07:00

Feel free to contact us if you have any further questions about UniDAC.

Tugrul Tamturk
Posts: 32
Joined: Mon 25 Aug 2008 18:28

Post by Tugrul Tamturk » Thu 03 Feb 2011 13:05

A problem with TableInfo is TableAlias is not show correct Alias name.. Mostly empty..

What is your advice?

Tugrul

Tugrul Tamturk
Posts: 32
Joined: Mon 25 Aug 2008 18:28

Post by Tugrul Tamturk » Thu 03 Feb 2011 13:11

I mean > TableInfo.TableAlias property.....

AndreyZ

Post by AndreyZ » Thu 03 Feb 2011 15:11

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.

Tugrul Tamturk
Posts: 32
Joined: Mon 25 Aug 2008 18:28

Post by Tugrul Tamturk » Sat 23 Jul 2011 12:38

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!

Tugrul Tamturk
Posts: 32
Joined: Mon 25 Aug 2008 18:28

Post by Tugrul Tamturk » Mon 25 Jul 2011 07:25

Hi, any comment? solution?

AndreyZ

Post by AndreyZ » Mon 25 Jul 2011 08:27

Thank you for the information. We have reproduced the problem and the investigation of the problem is in progress. As soon as we solve the problem we will let you khow.

AndreyZ

Post by AndreyZ » Fri 26 Aug 2011 08:32

We have investigated this problem. The point is that SQL Server doesn't return information about table aliases. That's why there is no possibility of determining correct table aliases.

Post Reply