views:

27

answers:

1

I am getting the following exception. There are two records in the table and 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: 
+2  A: 

I have typically seen this when the underlying connection was closed in between getting the reader and using the reader. If you are using a global connection check that it didn't get closed somewhere earlier.

For example the following code block will receive the 5018 error on the "read" since the connection was already closed.

        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();

If you move the cn.Close(); to after the read you should not get the error.

Edgar