当我升级到使用OracleManagedDataAccess提供程序时,下面的代码不起作用,我感到困惑,因为源代码从一开始就没有改变,而且它在生产服务器上。
我理解为什么它不起作用,因为它没有调用OracleDataReader.Read()
那么,这是一个被Oracle识别出来的错误吗?如果是的话你能指出文件吗?在项目简单引用4.112.4.0之前,现在我正在使用Oracle.ManagedDataAccess
其他人觉得这很有意思吗?
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
有什么想法吗?
切换到使用Oracle.ManagedDataAccess.dll之后,我收到了这个错误,这是预期的,但它之前的工作是对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>