Getting error when building a dynamic list

Posts   
 
    
hplloyd
User
Posts: 191
Joined: 29-Oct-2004
# Posted on: 05-Sep-2008 18:28:39   

Hi,

I am using v2.0 and I am building a Dynamic List but when I run the FetchTypedList command it generates and error saying

The column prefix 'Target_Demo2.dbo.CubeActivityUser' does not match with a table name or alias name used in the query

Target_Demo2 is the name of my database CubeActivityUser is the name of the table

Code I am using (cut down to the essentials is)

ResultsetFields myFields = new ResultsetFields(1);
myFields.DefineField(CubeActivityUserFieldIndex.ActivityCount, 0, Count","CubeActivityUser",AggregateFunction.Sum);

IRelationPredicateBucket myBucket = new RelationPredicateBucket();  


IGroupByCollection myGroupByClause = new GroupByCollection();
                    

DataTable myDynamicList = new DataTable();
myAdapter.FetchTypedList(myFields, myDynamicList, myBucket, 0, null, true, myGroupByClause);

return myDynamicList;

You can see that I am trying to simply return the sum of values in a field called ActivityCount.

However if I extend the code to include a group by it works fine (again cut down):

ResultsetFields myFields = new ResultsetFields(2);
myFields.DefineField(CubeActivityUserFieldIndex.ActivityWeek, 0, "ActivityWeek");
myFields.DefineField(CubeActivityUserFieldIndex.ActivityCount, 1, "Count","CubeActivityUser",AggregateFunction.Sum);

IRelationPredicateBucket myBucket = new RelationPredicateBucket();  

IGroupByCollection myGroupByClause = new GroupByCollection();
myGroupByClause.Add(myFields[0]);

DataTable myDynamicList = new DataTable();
myAdapter.FetchTypedList(myFields, myDynamicList, myBucket, 0, null, true, myGroupByClause);

return myDynamicList;

I cant understand why the second one works fine but the first one does not. Furthermore, when I copy the SQL statement generated into SQL Enterprise manager it works perfectly.

Please help simple_smile - no doubt I am doing something stupid!!

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 05-Sep-2008 20:28:45   

hplloyd wrote:

ResultsetFields myFields = new ResultsetFields(1);
myFields.DefineField(CubeActivityUserFieldIndex.ActivityCount, 0, Count","CubeActivityUser",AggregateFunction.Sum);

IRelationPredicateBucket myBucket = new RelationPredicateBucket();  


IGroupByCollection myGroupByClause = new GroupByCollection();
                    

DataTable myDynamicList = new DataTable();
myAdapter.FetchTypedList(myFields, myDynamicList, myBucket, 0, null, true, myGroupByClause);

return myDynamicList;

I don't see anything wrong here except a missing quote (") for the "Count" alias (that should be an oversight).

David Elizondo | LLBLGen Support Team