ORA-00955 Erorr - asp.net-core

Im trying to make migration from visual Studio. Im building a project with Razor pages ASP.NET Core With Oracle database and when i make the migration comes this error:
2020-03-17 22:32:15.351073 ThreadID:1 (ERROR) OracleRelationalCommand.Execute() : Oracle.ManagedDataAccess.Client.OracleException (0x80004005): ORA-00955: Es gibt bereits ein Objekt mit diesem Namen
at OracleInternal.ServiceObjects.OracleConnectionImpl.VerifyExecution(Int32& cursorId, Boolean bThrowArrayBindRelatedErrors, SqlStatementType sqlStatementType, Int32 arrayBindCount, OracleException& exceptionForArrayBindDML, Boolean& hasMoreRowsInDB, Boolean bFirstIterationDone)
at OracleInternal.ServiceObjects.OracleCommandImpl.ExecuteNonQuery(String commandText, OracleParameterCollection paramColl, CommandType commandType, OracleConnectionImpl connectionImpl, Int32 longFetchSize, Int64 clientInitialLOBFS, OracleDependencyImpl orclDependencyImpl, Int64[]& scnFromExecution, OracleParameterCollection& bindByPositionParamColl, Boolean& bBindParamPresent, OracleException& exceptionForArrayBindDML, OracleConnection connection, OracleLogicalTransaction& oracleLogicalTransaction, Boolean isFromEF)
at Oracle.ManagedDataAccess.Client.OracleCommand.ExecuteNonQuery()
at Oracle.EntityFrameworkCore.Storage.Internal.OracleRelationalCommandBuilderFactory.OracleRelationalCommandBuilder.OracleRelationalCommand.Execute(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary`2 parameterValues)

Related

The data reader is incompatible with the specified 'IAPD_DBModel.Table_Price

I'm developing a Web API using ASP.NET Web API 2 and Entity Framework to access the database. I call my SQL Server stored procedures which is very simple and should be returning one column as follows:
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[getnationalities]
AS
BEGIN
SET NOCOUNT ON;
SELECT DISTINCT
Table_Price.Price_Nationality AS 'name'
FROM
Table_Price;
END
and here is my vb code :
Namespace Controllers
Public Class NationalityController
Inherits ApiController
Public Function getcountries() As IHttpActionResult
Using entities As IAPD_DBEntities = New IAPD_DBEntities()
Return Ok(entities.getnationalities.ToList)
End Using
End Function
End Class
End Namespace
and here is the error I'm getting from postman
{
"message": "An error has occurred.",
"exceptionMessage": "The data reader is incompatible with the specified 'IAPD_DBModel.Table_Price'. A member of the type, 'Price_PK_ID', does not have a
corresponding column in the data reader with the same name.",
"exceptionType": "System.Data.Entity.Core.EntityCommandExecutionException",
"stackTrace": " at System.Data.Entity.Core.Query.InternalTrees.ColumnMapFactory.GetMemberOrdinalFromReader(DbDataReader storeDataReader, EdmMember member, EdmType currentType, Dictionary`2 renameList)\r\n at System.Data.Entity.Core.Query.InternalTrees.ColumnMapFactory.GetColumnMapsForType(DbDataReader storeDataReader, EdmType edmType, Dictionary`2 renameList)\r\n at System.Data.Entity.Core.Query.InternalTrees.ColumnMapFactory.CreateColumnMapFromReaderAndType(DbDataReader storeDataReader, EdmType edmType, EntitySet entitySet, Dictionary`2 renameList)\r\n at System.Data.Entity.Core.Query.InternalTrees.ColumnMapFactory.CreateFunctionImportStructuralTypeColumnMap(DbDataReader storeDataReader, FunctionImportMappingNonComposable mapping, Int32 resultSetIndex, EntitySet entitySet, StructuralType baseStructuralType)\r\n at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.FunctionColumnMapGenerator.System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.IColumnMapGenerator.CreateColumnMap(DbDataReader reader)\r\n at System.Data.Entity.Core.Objects.ObjectContext.MaterializedDataRecord[TElement](EntityCommand entityCommand, DbDataReader storeReader, Int32 resultSetIndex, ReadOnlyCollection`1 entitySets, EdmType[] edmTypes, ShaperFactory`1 shaperFactory, MergeOption mergeOption, Boolean streaming)\r\n at System.Data.Entity.Core.Objects.ObjectContext.CreateFunctionObjectResult[TElement](EntityCommand entityCommand, ReadOnlyCollection`1 entitySets, EdmType[] edmTypes, ExecutionOptions executionOptions)\r\n at System.Data.Entity.Core.Objects.ObjectContext.<>c__DisplayClass47`1.<ExecuteFunction>b__46()\r\n at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)\r\n at System.Data.Entity.Core.Objects.ObjectContext.<>c__DisplayClass47`1.<ExecuteFunction>b__45()\r\n at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)\r\n at System.Data.Entity.Core.Objects.ObjectContext.ExecuteFunction[TElement](String functionName, ExecutionOptions executionOptions, ObjectParameter[] parameters)\r\n at ProjectDataAccess.IAPD_DBEntities.getnationalities() in C:\\Users\\Junaida\\documents\\visual studio 2015\\Projects\\WebApplication7\\ProjectDataAccess\\DataAccessModel.Context.vb:line 5552\r\n at WebApplication7.Controllers.NationalityController.getcountries() in C:\\Users\\Junaida\\documents\\visual studio 2015\\Projects\\WebApplication7\\WebApplication7\\Controllers\\NationalityController.vb:line 13\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.AuthenticationFilterResult.<ExecuteAsync>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"
}
What I really target is to get a dataset or array of nationalities
Sorry, I don't know Entity Framework but I can get a list of data from a stored procedure.
Dim lstNationalities As New List(Of String)
Using cn As New SqlClient.SqlConnection("Your connection string")
Using cmd As New SqlClient.SqlCommand With {
.Connection = cn,
.CommandType = CommandType.StoredProcedure,
.CommandText = "getnationalities"}
cn.Open
Using dr As SqlClient.SqlDataReader = cmd.ExecuteReader
Do While dr.Read
lstNationalities.Add(dr.GetString(0))
Loop
End Using
End Using
End Using

Connection Automatically Timedout (Session Timeout)

I am currently working on an application in which the user logins to view/edit multiple types of report, so other users can see what changes have been made. But sometimes when the user is going to a new page the session automatically timeouts.
My code is:
Function Check_Access(ByVal strModule As String) As String
Dim drAccess As SqlClient.SqlDataReader, strUser As String
GetNetworkName()
strUser = HttpContext.Current.Session("LOGON_USER")
drAccess = SqlHelper.ExecuteReader(strConnOASIS, "Oasis.dbo.p_RPT_Check_Accessibility", strModule, strUser)
If drAccess.HasRows Then
If drAccess.Read() Then
Return drAccess.GetString(0)
End If
End If
drAccess.Close()
Return "0"
End Function
The source error is:
Line 45: strUser = HttpContext.Current.Session("LOGON_USER")
Line 46:
Line 47: drAccess = SqlHelper.ExecuteReader(strConnOASIS, "Oasis.dbo.p_RPT_Check_Accessibility", strModule, strUser) //Error
Line 48:
Line 49: If drAccess.HasRows Then
And lastly the Stack Trace:
[InvalidOperationException: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.]
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) +445
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) +318
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry) +132
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) +195
System.Data.SqlClient.SqlConnection.Open() +122
Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteReader(String connectionString, CommandType commandType, String commandText, SqlParameter[] commandParameters) +412
Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteReader(String connectionString, String spName, Object[] parameterValues) +442
OasisInclude.GlobalFunctions.Check_Access(String strModule) in E:\Danish\VSO\OasisRedesign\Dev\Oasis\OasisInclude\GlobalFunctions.vb:47
Residential.Residential.Page_Load(Object sender, EventArgs e) in E:\Danish\VSO\OasisRedesign\Dev\Oasis\Oasis\Residential\Residential.aspx.vb:56
System.Web.UI.Control.OnLoad(EventArgs e) +109
System.Web.UI.Control.LoadRecursive() +68
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3321
You are never closing the data reader if it returns data. All those open data readers are holding your database connections causing the error.
To fix it, change the code to:
Function Check_Access(ByVal strModule As String) As String
Dim drAccess As SqlClient.SqlDataReader, strUser As String
GetNetworkName()
strUser = HttpContext.Current.Session("LOGON_USER")
drAccess = SqlHelper.ExecuteReader(strConnOASIS, "Oasis.dbo.p_RPT_Check_Accessibility", strModule, strUser)
Try
If drAccess.HasRows Then
If drAccess.Read() Then
Return drAccess.GetString(0)
End If
End If
Finally
drAccess.Close()
End Try
Return "0"
End Function

How is it possible that not calling OracleDataReader.Read() still returns a row?

When I upgraded to use OracleManagedDataAccess provider, the code below did not work, I was baffled because the source code has never change since inception, and its on production server.
I understand why it does not work, as it not calling OracleDataReader.Read()
So, is this a bug that has been indentified by Oracle? Could you point to documentation if yes? Before project was simply referencing 4.112.4.0, now I'm using Oracle.ManagedDataAccess
Anyone else find this interesting?
Public Function GeCount(ByVal value As Integer) As Integer
Dim pCount As New PageCount
Using conn As OracleConnection = New OracleConnection(connString)
'conn.Open()
Using cmd As OracleCommand = New OracleCommand()
cmd.Connection = conn
pCount.PageCnt = 0
cmd.CommandText = "SELECT COUNT(*) FROM dual"
cmd.Connection.Open()
Using rdr As OracleDataReader = cmd.ExecuteReader()
If rdr.HasRows Then
If Not rdr.IsDBNull(0) Then pCount.PageCnt = CInt(CInt(rdr.GetDecimal(0)) / pSize)
End If
End Using
cmd.Connection.Close()
cmd.Dispose()
End Using
conn.Dispose()
End Using
Return pCount
End Function
Any ideas?
EDIT
After switching to use Oracle.ManagedDataAccess.dll, I get this error, which is expected, but it was working before with a reference to Oracle Data Access Client 4.112.4.0
- <Fault xmlns="http://schemas.microsoft.com/ws/2005/05/envelope/none">
- <Code>
<Value>Receiver</Value>
- <Subcode>
<Value xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:InternalServiceFault</Value>
</Subcode>
</Code>
- <Reason>
<Text xml:lang="en-US">Invalid attempt to read when no data is present</Text>
</Reason>
- <Detail>
- <ExceptionDetail xmlns="http://schemas.datacontract.org/2004/07/System.ServiceModel" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<HelpLink i:nil="true" />
<InnerException i:nil="true" />
<Message>Invalid attempt to read when no data is present</Message>
<StackTrace>at Oracle.ManagedDataAccess.Client.OracleDataReader.IsDBNull(Int32 i) at WcfRestService1.WcfRestService1.SiteEDocXRefRepository.GetSiteEDocCount(Int32 site_id) at WcfRestService1.WcfRestService1.EDocSvc.GetCntCollectionXRefSiteEDoc(String site_id) at SyncInvokeGetCntCollectionXRefSiteEDoc(Object , Object[] , Object[] ) at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</StackTrace>
<Type>System.InvalidOperationException</Type>
</ExceptionDetail>
</Detail>
</Fault>

A resource manager with the same identifier is already registered with the specified transaction coordinator

I am consistently getting ResourceManager error. I use below code:
public static IDocumentStore Initialize()
{
const string id = "2a5434cf-56f6-4b33-9661-5b6cc53bd9a5";
_instance = new DocumentStore
{
Url = "http://localhost:8085",
DefaultDatabase = "Testing",
ResourceManagerId = new Guid(id)
};
_instance.Initialize();
return _instance;
}
Here's the call stack:
2015-06-04 15:39:08.366 INFO NServiceBus.Unicast.Transport.TransportReceiver Failed to process message
System.Runtime.InteropServices.COMException (0x8004D102): A resource manager with the same identifier is already registered with the specified transaction coordinator. (Exception from HRESULT: 0x8004D102)
at System.Transactions.Oletx.IDtcProxyShimFactory.CreateResourceManager(Guid resourceManagerIdentifier, IntPtr managedIdentifier, IResourceManagerShim& resourceManagerShim)
at System.Transactions.Oletx.OletxResourceManager.get_ResourceManagerShim()
at System.Transactions.Oletx.OletxResourceManager.EnlistDurable(OletxTransaction oletxTransaction, Boolean canDoSinglePhase, IEnlistmentNotificationInternal enlistmentNotification, EnlistmentOptions enlistmentOptions)
at System.Transactions.Oletx.OletxTransaction.EnlistDurable(Guid resourceManagerIdentifier, ISinglePhaseNotificationInternal singlePhaseNotification, Boolean canDoSinglePhase, EnlistmentOptions enlistmentOptions)
at System.Transactions.TransactionStatePromotedBase.EnlistDurable(InternalTransaction tx, Guid resourceManagerIdentifier, IEnlistmentNotification enlistmentNotification, EnlistmentOptions enlistmentOptions, Transaction atomicTransaction)
at System.Transactions.Transaction.EnlistDurable(Guid resourceManagerIdentifier, IEnlistmentNotification enlistmentNotification, EnlistmentOptionsenlistmentOptions)
at Raven.Client.Document.InMemoryDocumentSessionOperations.TryEnlistInAmbientTransaction() in c:\Builds\RavenDB-Stable-3.0\Raven.Client.Lightweight\Document\InMemoryDocumentSessionOperations.cs:line 1082
at Raven.Client.Document.InMemoryDocumentSessionOperations.PrepareForSaveChanges() in c:\Builds\RavenDB-Stable-3.0\Raven.Client.Lightweight\Document\InMemoryDocumentSessionOperations.cs:line 931
at Raven.Client.Document.DocumentSession.SaveChanges() in c:\Builds\RavenDB-Stable-3.0\Raven.Client.Lightweight\Document\DocumentSession.cs:line 707
at NServiceBus.RavenDB.SessionManagement.OpenSessionBehavior.Invoke(IncomingContext context, Action next) in c:\BuildAgent\work\c4d62ce02b983878\src\NServiceBus.RavenDB\SessionManagement\OpenSessionBehavior.cs:line 22
[…]
Has anyone else come across this issue?
Here is the solution I found:
I had created 6 endpoints for each of the endpoint I was using same ResourceManagerId. Once I created different ResourceManagerId (constant guid) for each endpoint this issue got resolved.

Entity Framework v5.0 Exception 'From' is a reserved keyword and cannot be used as an alias, unless it is escaped

I use EntityFrameWork v5.0, EntityDataSource control.
In code I set SQL query, but when I open page after compilation I get exception. How can I fix it?
Code:
entryListDs.CommandParameters.Add(new Parameter("subId", DbType.Int32, Common.CurrentUserID.ToString()));
entryListDs.CommandParameters.Add(new Parameter("typeId", DbType.Int32, ((int)MessageType.Wall).ToString()));
entryListDs.CommandText = #"SELECT
m.ID,
m.To,
m.Subject,
m.BodyHtml,
m.CreationDate,
m.New,
m.TypeID
FROM
message AS m
JOIN subscription AS s
ON m.From = s.ObjectID
WHERE s.SubscriberID = #subId and m.TypeID = #typeId
ORDER BY m.CreationDate DESC";
Exeption when I open page:
'From' is a reserved keyword and cannot be used as an alias, unless it is escaped. Near line 12, column 6.
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.Data.EntitySqlException: 'From' is a reserved keyword and cannot be used as an alias, unless it is escaped. Near line 12, column 6.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[EntitySqlException: 'From' is a reserved keyword and cannot be used as an alias, unless it is escaped. Near line 12, column 6.]
System.Data.Common.EntitySql.CqlLexer.MapUnescapedIdentifier(String symbol) +8073331
System.Data.Common.EntitySql.CqlLexer.MapIdentifierOrKeyword(String symbol) +57
System.Data.Common.EntitySql.CqlLexer.Accept_83() +36
System.Data.Common.EntitySql.CqlLexer.yylex() +386
System.Data.Common.EntitySql.CqlParser.yylex() +16
System.Data.Common.EntitySql.CqlParser.yyparse() +132
System.Data.Common.EntitySql.CqlParser.internalParseEntryPoint() +101
System.Data.Common.EntitySql.CqlParser.Parse(String query) +148
System.Data.Common.EntitySql.CqlQuery.Parse(String commandText, ParserOptions parserOptions) +41
System.Data.Common.EntitySql.CqlQuery.CompileCommon(String commandText, Perspective perspective, ParserOptions parserOptions, Func`3 compilationFunction) +84
System.Data.Common.EntitySql.CqlQuery.CompileQueryCommandLambda(String queryCommandText, Perspective perspective, ParserOptions parserOptions, IEnumerable`1 parameters, IEnumerable`1 variables) +100
System.Data.Objects.EntitySqlQueryState.Parse() +8608663
System.Data.Objects.EntitySqlQueryState.GetResultType() +4
System.Data.Objects.ObjectQuery.GetResultType() +58
System.Web.UI.WebControls.EntityDataSourceQueryBuilder`1.BuildBasicQuery(ObjectContext context, Boolean computeCount) +108
System.Web.UI.WebControls.EntityDataSourceView.ExecuteSelectTyped(DataSourceSelectArguments arguments, Creator qbConstructor) +355
System.Web.UI.WebControls.EntityDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +606
System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +21
System.Web.UI.WebControls.DataBoundControl.PerformSelect() +138
System.Web.UI.WebControls.ListView.PerformSelect() +102
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +30
System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +105
System.Web.UI.WebControls.ListView.CreateChildControls() +52
System.Web.UI.Control.EnsureChildControls() +83
System.Web.UI.Control.PreRenderRecursiveInternal() +42
System.Web.UI.Control.PreRenderRecursiveInternal() +168
System.Web.UI.Control.PreRenderRecursiveInternal() +168
System.Web.UI.Control.PreRenderRecursiveInternal() +168
System.Web.UI.Control.PreRenderRecursiveInternal() +168
System.Web.UI.Control.PreRenderRecursiveInternal() +168
System.Web.UI.Control.PreRenderRecursiveInternal() +168
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +974
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18033
If you use keywords or special symbols in column names, then brackets are required. Just put column name in square brackets:
ON m.[From] = s.ObjectID
It says right there in your Exception: From is a reserved keyword.
In your query you have ON m.From = s.ObjectID. You need to rename your From column to something else.