Reputation: 825
Hi I have this link sentence what am I doing wrong?
FYI. This is an error after debugging.
Dim categories = Aggregate pgmAccess In rvdDB.PgmAccesses
Where pgmAccess.OperatorID = RData.UserName
Join menuDef In rvdDB.MenuDefs On menuDef.ProgramName Equals pgmAccess.Program
Order By menuDef.MenuID
Select menuDef.ProgramDescription
Distinct Into ToList()
Error message
An exception of type 'System.NotSupportedException' occurred in System.Data.Linq.dll but was not handled in user code
Additional information: Method 'System.Object CompareObjectEqual(System.Object, System.Object, Boolean)' has no supported translation to SQL.
__
Server Error in '/' Application.
Method 'System.Object CompareObjectEqual(System.Object, System.Object, Boolean)' has no supported translation to SQL.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NotSupportedException: Method 'System.Object CompareObjectEqual(System.Object, System.Object, Boolean)' has no supported translation to SQL.
Source Error:
Line 16: Dim rvdDB As New RVDDataClassesDataContext Line 17: Line 18: Dim categories = Aggregate pgmAccess In rvdDB.PgmAccesses Where pgmAccess.OperatorID = RData.UserName Join menuDef In rvdDB.MenuDefs On menuDef.ProgramName Equals pgmAccess.Program Order By menuDef.MenuID Select menuDef.ProgramDescription Distinct Into ToList() Line 19: Line 20:
categories.ForEach(AddressOf MakeButton)Source File: C:\Users\pieterv\Documents\Visual Studio 2013\Projects\RVDMenu\RVDMenu\MenuFrm.aspx.vb Line: 18
Stack Trace:
[NotSupportedException: Method 'System.Object CompareObjectEqual(System.Object, System.Object, Boolean)' has no supported translation to SQL.]
System.Data.Linq.SqlClient.Visitor.VisitMethodCall(SqlMethodCall mc) +576409 System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node) +2146 System.Data.Linq.SqlClient.SqlVisitor.VisitExpression(SqlExpression exp) +8
System.Data.Linq.SqlClient.Visitor.VisitMethodCall(SqlMethodCall mc) +115 System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node) +2146 System.Data.Linq.SqlClient.SqlVisitor.VisitExpression(SqlExpression exp) +8
System.Data.Linq.SqlClient.SqlVisitor.VisitSelectCore(SqlSelect select) +46
System.Data.Linq.SqlClient.Visitor.VisitSelect(SqlSelect select) +20
System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node) +1024
System.Data.Linq.SqlClient.SqlVisitor.VisitAlias(SqlAlias a) +13
System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node) +457
System.Data.Linq.SqlClient.SqlVisitor.VisitSource(SqlSource source) +8 System.Data.Linq.SqlClient.SqlVisitor.VisitJoin(SqlJoin join) +21
System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node) +979
System.Data.Linq.SqlClient.SqlVisitor.VisitSource(SqlSource source) +8 System.Data.Linq.SqlClient.SqlVisitor.VisitSelectCore(SqlSelect select) +27
System.Data.Linq.SqlClient.Visitor.VisitSelect(SqlSelect select) +20
System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node) +1024
System.Data.Linq.SqlClient.SqlVisitor.VisitAlias(SqlAlias a) +13
System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node) +457
System.Data.Linq.SqlClient.SqlVisitor.VisitSource(SqlSource source) +8 System.Data.Linq.SqlClient.SqlVisitor.VisitSelectCore(SqlSelect select) +27
System.Data.Linq.SqlClient.Visitor.VisitSelect(SqlSelect select) +20
System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node) +1024
System.Data.Linq.SqlClient.SqlVisitor.VisitAlias(SqlAlias a) +13
System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node) +457
System.Data.Linq.SqlClient.SqlVisitor.VisitSource(SqlSource source) +8 System.Data.Linq.SqlClient.SqlVisitor.VisitSelectCore(SqlSelect select) +27
System.Data.Linq.SqlClient.Visitor.VisitSelect(SqlSelect select) +20
System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node) +1024
System.Data.Linq.SqlClient.SqlVisitor.VisitAlias(SqlAlias a) +13
System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node) +457
System.Data.Linq.SqlClient.SqlVisitor.VisitSource(SqlSource source) +8 System.Data.Linq.SqlClient.SqlVisitor.VisitSelectCore(SqlSelect select) +27
System.Data.Linq.SqlClient.Visitor.VisitSelect(SqlSelect select) +20
System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node) +1024
System.Data.Linq.SqlClient.SqlProvider.BuildQuery(ResultShape resultShape, Type resultType, SqlNode node, ReadOnlyCollection1 parentParameters, SqlNodeAnnotations annotations) +588
1.System.Collections.Generic.IEnumerable.GetEnumerator() +35 System.Collections.Generic.List
System.Data.Linq.SqlClient.SqlProvider.BuildQuery(Expression query, SqlNodeAnnotations annotations) +155
System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query) +132
System.Data.Linq.DataQuery1..ctor(IEnumerable
1 collection) +7675130 System.Linq.Enumerable.ToList(IEnumerable`1 source) +61 RVDMenu.MenuFrm.LoadCategories() in C:\Users\pieterv\Documents\Visual Studio 2013\Projects\RVDMenu\RVDMenu\MenuFrm.aspx.vb:18
RVDMenu.MenuFrm.Page_Load(Object sender, EventArgs e) in C:\Users\pieterv\Documents\Visual Studio 2013\Projects\RVDMenu\RVDMenu\MenuFrm.aspx.vb:12
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
Upvotes: 0
Views: 1345
Reputation: 825
I fixed the issue RData.Username had to have .tostring now it works. Thanks @Yuriy Galanter
Upvotes: 0
Reputation: 17578
From your error:
Method 'System.Object CompareObjectEqual(System.Object, System.Object, Boolean)' has no supported translation to SQL
This means that you are doing an object comparison that SQL does not know how to perform.
The places I see that you are doing this comparison are:
Where pgmAccess.OperatorID = RData.UserName
On menuDef.ProgramName Equals pgmAccess.Program
You need to check what the datatypes of those properties are. Remember that SQL only knows how to compare common datatypes, like strings, ints, doubles, etc. It does not know how to compare datatypes that you create.
Upvotes: 2