从adsDataReader获取异常

时间:2010-08-16 18:05:44

标签: advantage-database-server

我收到以下异常。表中有两条记录,HasRows = true

Advantage.Data.Provider.AdsException was unhandled by user code
  Message="Error 5018:  The handle given was not recognized by Advantage. Verify specified handle is open/active.  The given handle is not recognized as a valid Advantage Client Engine handle."
  Source="Advantage.Data.Provider"
  Number=5018
  State=""
  StackTrace:
       at Advantage.Data.Provider.AdsException.CheckACE(UInt32 ulRet)
       at Advantage.Data.Provider.AdsDataReader.GetName(Int32 iCol)
       at Ceridian.Benefits.AdvantageDbAdapter.Utilities.SelectBodyWriter.OnWriteBodyContents(XmlDictionaryWriter writer)
       at System.ServiceModel.Channels.BodyWriter.WriteBodyContents(XmlDictionaryWriter writer)
       at System.ServiceModel.Channels.BodyWriterMessage.OnWriteBodyContents(XmlDictionaryWriter writer)
       at System.ServiceModel.Channels.Message.WriteBodyContents(XmlDictionaryWriter writer)
       at Ceridian.Benefits.AdvantageDbAdapter.Utilities.AdapterMessage.OnWriteBodyContents(XmlDictionaryWriter writer)
       at System.ServiceModel.Channels.Message.OnGetReaderAtBodyContents()
       at Ceridian.Benefits.AdvantageDbAdapter.Utilities.AdapterMessage.OnGetReaderAtBodyContents()
       at System.ServiceModel.Channels.Message.GetReaderAtBodyContents()
       at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeBodyContents(Message message, Object[] parameters, Boolean isRequest)
       at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeReply(Message message, Object[] parameters)
       at System.ServiceModel.Dispatcher.ProxyOperationRuntime.AfterReply(ProxyRpc& rpc)
       at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
       at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
       at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
  InnerException: 

1 个答案:

答案 0 :(得分:2)

在获取阅读器和使用阅读器之间关闭底层连接时,我通常会看到这一点。如果您正在使用全局连接,请检查它是否在某个地方之前没有关闭。

例如,由于连接已经关闭,以下代码块将在“读取”时收到5018错误。

        AdsConnection cn = new AdsConnection("data source=c:\\");
        cn.Open();
        AdsCommand cmd = cn.CreateCommand();
        cmd.CommandText = "EXECUTE PROCEDURE sp_mgGetInstallInfo()";
        AdsDataReader dr = cmd.ExecuteReader();
        cn.Close();
        dr.Read();

如果移动cn.Close();在阅读之后你不应该得到错误。