xxx "could not be bound"

Posts   
 
    
renesisx
User
Posts: 44
Joined: 07-Aug-2006
# Posted on: 19-Sep-2006 15:05:56   

Any ideas on this one guys?

"CaseStatus" table is included in the TypedList, and CaseStatusID is even one of the columns in the List.


        Dim objCaseSelectFilter As New PredicateExpression()
        objCaseSelectFilter.Add(CaseFields.UserAccountID = 1)
        objCaseSelectFilter.AddWithAnd(CaseStatusFields.CaseStatusID = 4)

        Dim objCaseList As New CaseListTypedList
        objCaseList.Fill(0, Nothing, False, objCaseSelectFilter)

        grvCases.DataSource = objCaseList
        grvCases.DataBind()

The multi-part identifier "MyDatabase.dbo.CaseStatus.CaseStatusID" could not be bound

Line 47: Public Function GetMultiAsDataTable(fieldsToReturn As IEntityFields, tableToFill As DataTable, maxNumberOfItemsToReturn As Long, sortClauses As ISortExpression, selectFilter As IPredicate, relations As IRelationCollection, allowDuplicates As Boolean, groupByClause As IGroupByCollection, transactionToUse As ITransaction, pageNumber As Integer, pageSize As Integer) As Boolean Line 48: Return MyBase.PerformGetMultiAsDataTableAction(fieldsToReturn, tableToFill, maxNumberOfItemsToReturn, sortClauses, selectFilter, relations, allowDuplicates, groupByClause, transactionToUse, pageNumber, pageSize) Line 49: End Function

Jessynoo avatar
Jessynoo
Support Team
Posts: 296
Joined: 19-Aug-2004
# Posted on: 19-Sep-2006 15:45:11   

Hi,

could you please give some information? What is your typedlist made of? What are the relation? Can you paste the exact exception stack?

Cheers

renesisx
User
Posts: 44
Joined: 07-Aug-2006
# Posted on: 19-Sep-2006 15:58:31   

Background:

There is a table called "Case" which has a relation to a table called "CaseStatus" which holds the different possible statuses of Case, such as "Open", "Closed", "In Progress".

They are linked by a key called "CaseStatusID".

Both tables are included in the TypedList, as I use 2 columns ("Description" and one other) from the CaseStatus table, and many columns from the Case table.

OK, full stack trace below. It's not the original as I've tried my best to replace confidential and propriety names and variables, but it shouldn't make a difference for you:


[SqlException (0x80131904): The multi-part identifier "MyDatabase.dbo.CaseStatus.CaseStatusID" could not be bound.]
   System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +177
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +68
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +199
   System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2305
   System.Data.SqlClient.SqlDataReader.ConsumeMetaData() +31
   System.Data.SqlClient.SqlDataReader.get_MetaData() +62
   System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +294
   System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +1021
   System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +314
   System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +20
   System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) +107
   System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) +10
   System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) +7
   System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +139
   System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior) +161
   System.Data.Common.DbDataAdapter.Fill(DataTable dataTable) +105
   SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.ExecuteMultiRowDataTableRetrievalQuery(IRetrievalQuery queryToExecute, DbDataAdapter dataAdapterToUse, DataTable tableToFill, IEntityFields fieldsToReturn) +622
   SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.PerformGetMultiAsDataTableAction(IEntityFields fieldsToReturn, DataTable tableToFill, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IPredicate selectFilter, IRelationCollection relations, Boolean allowDuplicates, IGroupByCollection groupByClause, ITransaction transactionToUse, Int32 pageNumber, Int32 pageSize) +147
   MyCompany.MyProject.MySubProject.Data.DaoClasses.TypedListDAO.GetMultiAsDataTable(IEntityFields fieldsToReturn, DataTable tableToFill, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IPredicate selectFilter, IRelationCollection relations, Boolean allowDuplicates, IGroupByCollection groupByClause, ITransaction transactionToUse, Int32 pageNumber, Int32 pageSize) in C:\Documents and Settings\john.doe\My Documents\LLBLGen Pro Projects\MyDatabase\DaoClasses\TypedListDAO.vb:48
   MyCompany.MyProject.MySubProject.Data.TypedListClasses.CaseListTypedList.Fill(Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, Boolean allowDuplicates, IPredicate selectFilter, ITransaction transactionToUse, IGroupByCollection groupByClause, Int32 pageNumber, Int32 pageSize) in C:\Documents and Settings\john.doe\My Documents\LLBLGen Pro Projects\MyDatabase\TypedListClasses\CaseListTypedList.vb:218
   MyCompany.MyProject.MySubProject.Data.TypedListClasses.CaseListTypedList.Fill(Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, Boolean allowDuplicates, IPredicate selectFilter) in C:\Documents and Settings\john.doe\My Documents\LLBLGen Pro Projects\MyDatabase\TypedListClasses\CaseListTypedList.vb:163
   MySubProject_Cases_Search.Page_Load(Object sender, EventArgs e) in C:\Documents and Settings\john.doe\My Documents\Visual Studio 2005\WebSites\MyDatabase\MySubProject\Cases\Search.aspx.vb:35
   System.Web.UI.Control.OnLoad(EventArgs e) +80
   System.Web.UI.Control.LoadRecursive() +49
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3745

Jessynoo avatar
Jessynoo
Support Team
Posts: 296
Joined: 19-Aug-2004
# Posted on: 19-Sep-2006 16:23:59   

Do you confirm that this only happens when you add the corresponding filter:

 objCaseSelectFilter.AddWithAnd(CaseStatusFields.CaseStatusID = 4)

Did you tried commenting that line?

If the filter is the cause, there might be some reason for which the aliases used don't match the one of the typedlist.

Then what happens if you get the field from the BuildResultset function (used for building the query) rather than by using the CaseStatusFields.CaseStatusID factory?

renesisx
User
Posts: 44
Joined: 07-Aug-2006
# Posted on: 19-Sep-2006 17:14:29   

Yes, if I comment out that line it works perfectly. (except that my results aren't filtered how I want..)

I'm not sure how to do what you ask with the BuildResultSet function.. do you have an example?

Jessynoo avatar
Jessynoo
Support Team
Posts: 296
Joined: 19-Aug-2004
# Posted on: 19-Sep-2006 17:24:23   

Sure,

 Dim caseStatusFields As IEntityFields = yourCaseListTypedList.BuildResultset
        Dim caseStatusIDField As IEntityField = caseStatusFields("CaseStatusID")
        objCaseSelectFilter.AddWithAnd(caseStatusIDField  = 4)

Might not be solve the problem, but it's worth a try

renesisx
User
Posts: 44
Joined: 07-Aug-2006
# Posted on: 19-Sep-2006 17:33:22   

flushed flushed

I'd re-generated the project but forgotten to re-build the LLBLGen output project.

Yes, I am an idiot...

Everything works fine now confused

Jessynoo avatar
Jessynoo
Support Team
Posts: 296
Joined: 19-Aug-2004
# Posted on: 19-Sep-2006 17:42:00   

That was my first thought, but for some reason, I didn't question your dlls. Good that you found it anyway wink