Devart "Error on executing DbCommand." - mysql

Hi i've this kind of exception using Devart. I'm calling a store procedure in MySql. The Store procedure function if i call it by DB.
using (dc = conn.GetContext())
{
result = dc.StoreProcedure(pId).FirstOrDefault();
}
return result;
[MySqlException (0x80004005): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(7003172) t1 LIMIT 1' at line 2]
Devart.Data.MySql.bk.s() +270
Devart.Data.MySql.bk.d() +200
Devart.Data.MySql.v.a(ah[]& A_0, Int32& A_1) +134
Devart.Data.MySql.v.a(Byte[] A_0, Int32 A_1, Boolean A_2) +106
Devart.Data.MySql.a3.e() +169
Devart.Data.MySql.a3.o() +89
Devart.Data.MySql.MySqlCommand.InternalExecute(CommandBehavior behavior, IDisposable stmt, Int32 startRecord, Int32 maxRecords) +1472
Devart.Common.DbCommandBase.InternalExecute(CommandBehavior behavior, IDisposable stmt, Int32 startRecord, Int32 maxRecords, Boolean nonQuery) +48
Devart.Common.DbCommandBase.ExecuteDbDataReader(CommandBehavior behavior, Boolean nonQuery) +764
Devart.Common.DbCommandBase.ExecuteDbDataReader(CommandBehavior behavior) +38
System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader() +12
Devart.Data.Linq.Provider.DataProvider.a(b A_0, Object[] A_1, Object[] A_2, Object A_3) +1436
[LinqCommandExecutionException: Error on executing DbCommand.]
Devart.Data.Linq.LinqCommandExecutionException.a(String A_0, Exception A_1) +79
Devart.Data.Linq.Provider.DataProvider.a(b A_0, Object[] A_1, Object[] A_2, Object A_3) +5349
Devart.Data.Linq.Provider.DataProvider.a(b A_0, Object[] A_1) +65
Devart.Data.Linq.Provider.DataProvider.h(Expression A_0) +189
Devart.Data.Linq.DataQuery`1.System.Linq.IQueryProvider.Execute(Expression expression) +53
System.Linq.Queryable.FirstOrDefault(IQueryable`1 source) +269`

Apparently, the problem is that the procedure is marked as 'pipelined' in the model. In this case, it is supposed that the procedure has a return value which is a result set. Thus, the LinqConnect runtime tries to perform a select from this result set (ending with the 'limit 1' clause because of the 'FirstOrDefault' method).
Since MySql functions cannot retrieve result sets as return values, this behaviour leads to a MySQL error. To resolve the problem, please try setting the 'Pipelined' property of this procedure to 'false'.

Related

Entity Framework execute RawSql on MySQL Database

I am using EntityFramework to connect to a MySql server.
I have a method which inserts many objects in the database. For this, i am generating an SQL script, which i execute it using dbContext.Database.ExecuteSqlCommand(script) method.
This workflow works ok when the EntityFramework was connected to MS SQL Server.
Now, after i moved it to MySql, it throws error when executing the script.
Incorrect syntax near '`'.
Important
The script had been generated to match MySql syntax. If i run that script in MySQL Workbench, the query is executed successfully.
I think that EntityFramework is trying to parse the script i am sending, but in the MS SQL language.
Here is the exception Stack Trace:
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.<NonQuery>b__0(DbCommand t, DbCommandInterceptionContext`1 c)
at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.NonQuery(DbCommand command, DbCommandInterceptionContext interceptionContext)
at System.Data.Entity.Internal.InterceptableDbCommand.ExecuteNonQuery()
at System.Data.Entity.Core.Objects.ObjectContext.<>c__DisplayClass59.<ExecuteStoreCommand>b__58()
at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
at System.Data.Entity.Core.Objects.ObjectContext.<>c__DisplayClass59.<ExecuteStoreCommand>b__57()
at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)
at System.Data.Entity.Core.Objects.ObjectContext.ExecuteStoreCommand(TransactionalBehavior transactionalBehavior, String commandText, Object[] parameters)
at System.Data.Entity.Internal.InternalContext.ExecuteSqlCommand(TransactionalBehavior transactionalBehavior, String sql, Object[] parameters)
at System.Data.Entity.Database.ExecuteSqlCommand(TransactionalBehavior transactionalBehavior, String sql, Object[] parameters)
at System.Data.Entity.Database.ExecuteSqlCommand(String sql, Object[] parameters)
at AppFormApp.Domain.EntityFramework.AppFormAppDatabaseService.<InsertAllObjectsAsync>d__1.MoveNext() in F:\GitRoot\AppFormApp\AppFormApp\AppFormApp.Domain\EntityFramework\AppFormAppDatabaseService.cs:line 120
UPDATE
This is the MySQL query generated
INSERT INTO `appformapp`.`appformdata`(`Id`, `ApplicationIdentifier`, `ApplicationName`, `LastSavedDate`, `LastActivity`)
VALUES (N'59bbf577-d601-4857-aabf-84b69b2d7b75', N'APP-TMH3EI', N'Test ABV', N'2016-10-17 05:56:16', N'2016-10-17 05:56:16');
The Entity Framework is already working with MySql. The error is only triggered when using dbContext.Database.ExecuteSqlCommand(script)

Understanding and investigating CommitFailedException on MySQL

I have an Entity Framework-based application running in production.
Since a couple of days some customers are calling for random Internal Server Errors. Log files show that a simple transaction, with a single INSERT statement, is failing to commit, and that transaction is related to logging.
Let me explain better....
I have inherited a database logging feature that thanks to a controller method attribute will log every HTTP request to database to make a navigation log. Last year I have refactored the whole application from plain old multi-dialect SQL/ADO (because app runs on both MySQL and SQL Server) to Entity Framework. The application went in production and only little maintenance was required, up to major release 3.0 which is in prod for more than a month.
From yesterday, we received multiple complaints that I found related to the following exception
System.Data.Entity.Infrastructure.CommitFailedException: [non-English description] http://go.microsoft.com/fwlink/?LinkId=313468. ---> MySql.Data.MySqlClient.MySqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. ---> System.TimeoutException: Timeout in IO operation
in MySql.Data.MySqlClient.TimedStream.StopTimer()
in MySql.Data.MySqlClient.TimedStream.Read(Byte[] buffer, Int32 offset, Int32 count)
in System.IO.BufferedStream.Read(Byte[] array, Int32 offset, Int32 count)
in MySql.Data.MySqlClient.MySqlStream.ReadFully(Stream stream, Byte[] buffer, Int32 offset, Int32 count)
in MySql.Data.MySqlClient.MySqlStream.LoadPacket()
in MySql.Data.MySqlClient.MySqlStream.ReadPacket()
in MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId)
in MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
in MySql.Data.MySqlClient.MySqlDataReader.NextResult()
in MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
--- Fine della traccia dello stack dell'eccezione interna ---
in MySql.Data.MySqlClient.ExceptionInterceptor.Throw(Exception exception)
in MySql.Data.MySqlClient.MySqlConnection.HandleTimeoutOrThreadAbort(Exception ex)
in MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
in MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery()
in MySql.Data.MySqlClient.MySqlTransaction.Commit()
in System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext](TTarget target, Action`2 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
--- Fine della traccia dello stack dell'eccezione interna ---
in System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext](TTarget target, Action`2 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
in System.Data.Entity.Infrastructure.Interception.DbTransactionDispatcher.Commit(DbTransaction transaction, DbInterceptionContext interceptionContext)
in System.Data.Entity.Core.EntityClient.EntityTransaction.Commit()
in System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
in System.Data.Entity.Core.Objects.ObjectContext.SaveChangesToStore(SaveOptions options, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction)
in System.Data.Entity.Core.Objects.ObjectContext.SaveChangesInternal(SaveOptions options, Boolean executeInExistingTransaction)
in System.Data.Entity.Internal.InternalContext.SaveChanges()
in DiagnosticoSite.Data.Managers.Spring.NavigationLogManagerImpl.Insert(String aUserId, DateTime aRequestDate, String aPath, String aQuery, String aHost, String aBrowser, String aExecutionTime)
The code
Code that runs the query is extremely simple
public void Insert(string aUserId, DateTime aRequestDate, string aPath, string aQuery, string aHost, string aBrowser, string aExecutionTime)
{
using (MyContext dataContext = GetDataContext())
{
LogNavigation log = new LogNavigation
{
LN_RequestDate = aRequestDate,
LN_Path = aPath,
LN_Query = aQuery,
LN_Host = aHost,
LN_Browser = aBrowser,
LN_ExecutionTime = aExecutionTime,
LN_FK_Utenti = aUserId
};
dataContext.log_navigation.Add(log);
dataContext.SaveChanges();
}
}
GetDataContext() is a Spring lookup method that returns new MyDataContext() as a Spring prototype object.
The application is DB-heavy, in the sense that it normally runs queries that take up to minutes to complete, but those readonly queries and the log navigation queries reasonably run on different connections/transactions.
What I have tried
Currently DB timeout is very high. Following is Spring XML configuration
<object id="DataContext" singleton="false" type="MyPackage.MyDataContext, MyAssembly" >
<property name="Database.CommandTimeout" value="3600" />
<property name="Configuration.UseDatabaseNullSemantics" value="true" />
</object>
I have also tried to investigate slow-query-log without finding any INSERT
Workaround
Currently the workaround to this issue was to try-catch the logging facility and log possible exception to log4net's system log. But that is a workaround. Like when you take a painkiller instead of properly treating an inflammation I mean.
The question is
How do I investigate the root cause of such timeouts during the execution of a single-statement transaction?

System.Data.Entity.Infrastructure.DbUpdateException error

I have a simple MVC 5 test solution that is connected to a SQL server 2008 on the intranet here. I have followed this tutorial so far:
http://www.asp.net/mvc/overview/getting-started/database-first-development/generating-views
I can open the view, and it shows the listing but when I try to create a new one I get the following error:
{"Unable to update the EntitySet 'Movies' because it has a
DefiningQuery and no <InsertFunction> element exists in the
<ModificationFunctionMapping> element to support the current
operation."}
I used the Database first approach so I have no idea what has gone wrong. I understand that somehow he can't perform an Update. Is this something I need to fix inside the project or has it to do something with SQl server?
EDIT: here is the exception details
System.Data.Entity.Infrastructure.DbUpdateException was unhandled by user code
HResult=-2146233087
Message=Unable to update the EntitySet 'Movies' because it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation.
Source=EntityFramework
StackTrace:
at System.Data.Entity.Internal.InternalContext.SaveChanges()
at System.Data.Entity.Internal.LazyInternalContext.SaveChanges()
at System.Data.Entity.DbContext.SaveChanges()
at TestSite.Controllers.MoviesController.Create(Movy movy) in c:\Users\Rovc\Desktop\TestSite\TestSite\Controllers\MoviesController.cs:line 54
at lambda_method(Closure , ControllerBase , Object[] )
at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.ActionInvocation.InvokeSynchronousActionMethod()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
at System.Web.Mvc.Async.AsyncResultWrapper.End[TResult](IAsyncResult asyncResult, Object tag)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
InnerException: System.Data.Entity.Core.UpdateException
HResult=-2146232032
Message=Unable to update the EntitySet 'Movies' because it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation.
Source=EntityFramework.SqlServer
StackTrace:
at System.Data.Entity.SqlServer.SqlGen.DmlSqlGenerator.ExpressionTranslator.Visit(DbScanExpression expression)
at System.Data.Entity.Core.Common.CommandTrees.DbScanExpression.Accept(DbExpressionVisitor visitor)
at System.Data.Entity.SqlServer.SqlGen.DmlSqlGenerator.GenerateInsertSql(DbInsertCommandTree tree, SqlGenerator sqlGenerator, List`1& parameters, Boolean generateReturningSql, Boolean upperCaseKeywords, Boolean createParameters)
at System.Data.Entity.SqlServer.SqlGen.SqlGenerator.GenerateSql(DbCommandTree tree, SqlVersion sqlVersion, List`1& parameters, CommandType& commandType, HashSet`1& paramsToForceNonUnicode)
at System.Data.Entity.SqlServer.SqlProviderServices.CreateCommand(DbProviderManifest providerManifest, DbCommandTree commandTree)
at System.Data.Entity.SqlServer.SqlProviderServices.CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree)
at System.Data.Entity.Core.Common.DbProviderServices.CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree, DbInterceptionContext interceptionContext)
at System.Data.Entity.Core.Common.DbProviderServices.CreateCommandDefinition(DbCommandTree commandTree, DbInterceptionContext interceptionContext)
at System.Data.Entity.Core.Common.DbProviderServices.CreateCommand(DbCommandTree commandTree, DbInterceptionContext interceptionContext)
at System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.CreateCommand(DbModificationCommandTree commandTree)
at System.Data.Entity.Core.Mapping.Update.Internal.DynamicUpdateCommand.CreateCommand(Dictionary`2 identifierValues)
at System.Data.Entity.Core.Mapping.Update.Internal.DynamicUpdateCommand.Execute(Dictionary`2 identifierValues, List`1 generatedValues)
at System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.Update()
at System.Data.Entity.Core.EntityClient.Internal.EntityAdapter.<Update>b__2(UpdateTranslator ut)
at System.Data.Entity.Core.EntityClient.Internal.EntityAdapter.Update[T](T noChangesResult, Func`2 updateFunction)
at System.Data.Entity.Core.EntityClient.Internal.EntityAdapter.Update()
at System.Data.Entity.Core.Objects.ObjectContext.<SaveChangesToStore>b__35()
at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
at System.Data.Entity.Core.Objects.ObjectContext.SaveChangesToStore(SaveOptions options, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction)
at System.Data.Entity.Core.Objects.ObjectContext.<>c__DisplayClass2a.<SaveChangesInternal>b__27()
at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)
at System.Data.Entity.Core.Objects.ObjectContext.SaveChangesInternal(SaveOptions options, Boolean executeInExistingTransaction)
at System.Data.Entity.Core.Objects.ObjectContext.SaveChanges(SaveOptions options)
at System.Data.Entity.Internal.InternalContext.SaveChanges()
InnerException:
I found the problem. The table that I was using was apparently missing a primary key. Once I designated the correct field as Primary everything worked.

ASP.Net Linq to read database is not working

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
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.System.Collections.Generic.IEnumerable.GetEnumerator()
+35 System.Collections.Generic.List1..ctor(IEnumerable1 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
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.
I fixed the issue RData.Username had to have .tostring now it works. Thanks #Yuriy Galanter

Downloading a file from http location, I get the following error

Scenario
Downloading an xlsx file to my local drive from a http location using a execute script task .
ERROR
Error: 0x1 at Script Task: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Net.WebException: The remote server returned an error: (401) Unauthorized.
at System.Net.WebClient.DownloadFile(Uri address, String fileName)
at ST_3926c89e45574d05b1869761d015ffc0.csproj.ScriptMain.Main()
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()
Task failed: Script Task
Warning: 0x80019002 at Package: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED. The Execution method succeeded, but the number of errors raised (1) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors.
SSIS package "Package.dtsx" finished: Failure.
Based on the code provided in your previous (and open) question I presume you would need to set the Credentials property on the HttpWebRequest. Without knowing the specifics of your credential situation, I cannot say whether the DefaultCredentials will work or whether you will need to provide a user & password.
wr.Credentials = System.Net.CredentialCache.DefaultCredentials;