The multi-part identifier \"MyNameSpace.dbo.Client.Lastname\" could not be bound.

Posts   
 
    
shughart
User
Posts: 5
Joined: 11-Nov-2006
# Posted on: 13-Nov-2006 04:06:49   

Hi

I'm getting an SQL exception "The multi-part identifier \"MyNameSpace.dbo.Client.Lastname\" could not be bound." when I run this code and can't seem to figure it out. It may seem simple but I can't find any documentation on this error.


// I just want to filter my search which is simple by last name e.g. McDonald but an exception is thrown

    // just a db view of firstname, lastname, etc...
    SearchClientTypedView sc = new SearchClientTypedView();  

    IPredicateExpression filter = new PredicateExpression();

    // By definition it the Fill method is Fill(long maxNumberOfItemsToReturn, ISortExpression sortClauses, bool allowDuplicates, IPredicate selectFilter)
    sc.Fill(0, null, true, filter.Add(ClientFields.Lastname == "McDonald"));

    dgvSearchResultsPane.DataSource = sc;

If I use this code it works and NO exception is thrown!

    

    sc.Fill(0, null, true, null);


I'm using LLBLgen 2.0.0.0final (Oct 23) assembly: SD.LLBLGen.Pro.ORMSupportClasses.NET20 version: v2.0.50727 Microsoft Visual C# 2005 MS .net framework 2.0.50727 I'm using the Self servicing template Running on MS Sqlexpress 2005

Here is the exception stack trace

System.Data.SqlClient.SqlException was unhandled Message="The multi-part identifier \"MyNameSpace.dbo.Client.Lastname\" could not be bound." Source=".Net SqlClient Data Provider" ErrorCode=-2146232060 Class=16 LineNumber=1 Number=4104 Procedure="" Server=".\sqlexpress" State=1 StackTrace: at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlDataReader.ConsumeMetaData() at System.Data.SqlClient.SqlDataReader.get_MetaData() at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable) at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.ExecuteMultiRowDataTableRetrievalQuery(IRetrievalQuery queryToExecute, DbDataAdapter dataAdapterToUse, DataTable tableToFill, IEntityFields fieldsToReturn) at 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) at Evergold.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 E:\jmak\work\systembind\customer\evergold\code\v0.11_llblgen_jag_gui\DaoClasses\TypedListDAO.cs:line 49 at Evergold.TypedViewClasses.SearchClientTypedView.Fill(Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, Boolean allowDuplicates, IPredicate selectFilter, ITransaction transactionToUse, IGroupByCollection groupByClause, Int32 pageNumber, Int32 pageSize) in E:\jmak\work\systembind\customer\evergold\code\v0.11_llblgen_jag_gui\TypedViewClasses\SearchClientTypedView.cs:line 218 at Evergold.TypedViewClasses.SearchClientTypedView.Fill(Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, Boolean allowDuplicates, IPredicate selectFilter) in E:\jmak\work\systembind\customer\evergold\code\v0.11_llblgen_jag_gui\TypedViewClasses\SearchClientTypedView.cs:line 157 at EvergoldAppClient.frmSearch.btnSearch_Click(Object sender, EventArgs e) in E:\jmak\work\systembind\customer\evergold\code\v0.11_llblgen_jag_gui\EvergoldAppClient\frmSearch.cs:line 32 at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ButtonBase.WndProc(Message& m) at System.Windows.Forms.Button.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods. IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(Form mainForm) at EvergoldAppClient.Program.Main() in E:\jmak\work\systembind\customer\evergold\code\v0.11_llblgen_jag_gui\EvergoldAppClient\Program.cs:line 17 at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()

I need some suggestion or points to resolve this problem. Thanks!

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 13-Nov-2006 07:52:08   

If you inspect the generated query, you may see this:

You're fetching from a view and filtering on a field on a table (ClientFields.Lastname) And that table is not part of any join or something.

So instead use the fields of the TypedView for filtering. (eg. SearchClientFields.LasName)

shughart
User
Posts: 5
Joined: 11-Nov-2006
# Posted on: 14-Nov-2006 05:03:54   

It must have been late and missed the small detail.

Thanks that did the trick!

Jason