Page 1 of 1

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

Posted: Wed 15 Dec 2010 06:36
by Tugrul Tamturk
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

Posted: Wed 15 Dec 2010 10:47
by AndreyZ
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;

Posted: Thu 16 Dec 2010 19:30
by Tugrul Tamturk
Thanks Andrey,

TCRFieldDesc declared CRAccess unit by the way..

Regards
Tugrul

Posted: Fri 17 Dec 2010 07:00
by AndreyZ
Feel free to contact us if you have any further questions about UniDAC.

Posted: Thu 03 Feb 2011 13:05
by Tugrul Tamturk
A problem with TableInfo is TableAlias is not show correct Alias name.. Mostly empty..

What is your advice?

Tugrul

Posted: Thu 03 Feb 2011 13:11
by Tugrul Tamturk
I mean > TableInfo.TableAlias property.....

Posted: Thu 03 Feb 2011 15:11
by 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.

Posted: Sat 23 Jul 2011 12:38
by Tugrul Tamturk
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!

Posted: Mon 25 Jul 2011 07:25
by Tugrul Tamturk
Hi, any comment? solution?

Posted: Mon 25 Jul 2011 08:27
by AndreyZ
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.

Posted: Fri 26 Aug 2011 08:32
by AndreyZ
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.