System.Data.SqlClient.SqlException

Posts   
 
    
Ken
User
Posts: 3
Joined: 18-Mar-2005
# Posted on: 04-Apr-2005 05:40:00   

Hi guys,

I'm having trouble extracting data from the typed list that I created. My code is:

**Dim typedList As New MyTypedList Dim fields As IEntityFields2 = MyTypedList.GetFieldsInfo()

Dim bucket As New RelationPredicateBucket bucket.PredicateExpression.Add(PredicateFactory.CompareValue( _ EmployeeTblFieldIndex.EmployeeId, _ ComparisonOperator.Equal, employeeId))

Dim adapter As New DataAccessAdapter adapter.FetchTypedList(fields, MyTypedList, bucket)**

If I run this code, i get the following SqlException:

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

I did some researching and found another approach using the GetRelationInfo property of the typedlist so i modified my bucket definition as:

Dim bucket As IRelationPredicateBucket = MyTypedList.GetRelationInfo()

What happens is I get rid of the exception but the typedlist does not contain anything (returns just the headers)

Is there something wrong with my code or with the way I formed the typedlist?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 04-Apr-2005 09:33:37   

Ken wrote:

Hi guys,

I'm having trouble extracting data from the typed list that I created. My code is:

**Dim typedList As New MyTypedList Dim fields As IEntityFields2 = MyTypedList.GetFieldsInfo()

Dim bucket As New RelationPredicateBucket bucket.PredicateExpression.Add(PredicateFactory.CompareValue( _ EmployeeTblFieldIndex.EmployeeId, _ ComparisonOperator.Equal, employeeId))

Dim adapter As New DataAccessAdapter adapter.FetchTypedList(fields, MyTypedList, bucket)**

If I run this code, i get the following SqlException:

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

I did some researching and found another approach using the GetRelationInfo property of the typedlist so i modified my bucket definition as:

Dim bucket As IRelationPredicateBucket = MyTypedList.GetRelationInfo()

You definitely have to do that indeed, otherwise the relations on which the typed list is build aren't passed to the fetch routine.

What happens is I get rid of the exception but the typedlist does not contain anything (returns just the headers)

Is there something wrong with my code or with the way I formed the typedlist?

Could you check if in the EmployeeTbl table there is indeed a record for EmployeeId = the value in employeeid ?

Frans Bouma | Lead developer LLBLGen Pro
Ken
User
Posts: 3
Joined: 18-Mar-2005
# Posted on: 06-Apr-2005 03:52:33   

Yep. It returns 5 rows when I do the select in the query analyzer.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 06-Apr-2005 12:02:36   

Ken wrote:

Yep. It returns 5 rows when I do the select in the query analyzer.

With all the joins (INNER JOIN) as well? Strange. The filter is:

WHERE Employee_TBL.EmployeeId = @parameter

I'm not familiar with the rest of the typed list. The Typed list will produce a select of the fields you selected in the typed list editor, perform an INNER JOIN in the relations you've specified and use the where above. Could you give some more information about the tables, the relations and the typed list elements you added to the typed list? (i.e.: which relations, which fields)

Also, if you use sqlprofiler, what query is executed on the db?

Frans Bouma | Lead developer LLBLGen Pro