Error message when opening a recordset with a strem containing xml



I have a problem when trying to open a recordset with a stream including xml
content.

The code line that triggers the error looks like this:

tempRecordsetClass.Open(xmlStream, tempRecordsetClass.Source,
tempRecordsetClass.CursorType, tempRecordsetClass.LockType, (int)
ADODB.CommandTypeEnum.adCmdUnspecified);

I get the following error message:

System.Runtime.InteropServices.COMException
Message = [Microsoft][ODBC Driver Manager] Data source name not found and no
default driver specified

I have also modified some of the parameters so it looks like this:

tempRecordsetClass.Open ((ADODB._Stream)xmlStream, noParam,
ADODB.CursorTypeEnum.adOpenUnspecified, ADODB.LockTypeEnum.adLockUnspecified,
(int)ADODB.CommandTypeEnum.adCmdUnspecified);

where noParam is a system object with the value
"System.Reflection.Missing.Value"

But then I get another error message instead:

System.InvalidCastException
Message = Unable to cast COM object of type 'System.__ComObject' to class
type 'ADODB.RecordsetClass'. COM components that enter the CLR and do not
support IProvideClassInfo or that do not have any interop assembly registered
will be wrapped in the __ComObject type. Instances of this type cannot be
cast to any other class; however they can be cast to interfaces as long as
the underlying COM component supports QueryInterface calls for the IID of the
interface.

Now I need your help, please.

The total content of the module is the following:

public virtual Recordset toRecordset(Document doc, Recordset rsEmptyAI)
{
System.String xml = null;
Recordset rsNewAI = new Recordset();
_Stream xmlStream = new Stream();
System.Object noParam = new System.Object();
noParam = System.Reflection.Missing.Value;
System.String schemaText = null;

ADODB.RecordsetClass rsUnmodifiedWFC = new ADODB.RecordsetClass();
ADODB.RecordsetClass rsNewWFC = null;

try
{
// save the empty recordset to a stream
rsEmptyAI.Save(xmlStream, PersistFormatEnum.adPersistXML);
schemaText = xmlStream.ReadText((int)StreamReadEnum.adReadAll);

// get just to <rs:data>
schemaText = schemaText.Substring(0,
(schemaText.IndexOf(com.volvo.vtc.sprint.bussvc.assembly.copybtwfactories.xml.IElements.rs_data)) - (0));

xml = XMLHelper.toXML(doc);

// get from <rs:data> to end
xml =
xml.Substring(xml.IndexOf(com.volvo.vtc.sprint.bussvc.assembly.copybtwfactories.xml.IElements.rs_data),
(xml.Length) -
(xml.IndexOf(com.volvo.vtc.sprint.bussvc.assembly.copybtwfactories.xml.IElements.rs_data)));
xml = schemaText + xml;

// get a new stream
xmlStream = new Stream();

// open the stream
xmlStream.Open(noParam, ADODB.ConnectModeEnum.adModeUnknown,
ADODB.StreamOpenOptionsEnum.adOpenStreamUnspecified, null, null);

// write to a stream
xmlStream.WriteText(xml, ADODB.StreamWriteEnum.adWriteChar);
xmlStream.Flush();

// set cursor at the begining
xmlStream.Position=0;

ADODB.RecordsetClass tempRecordsetClass;
tempRecordsetClass = rsUnmodifiedWFC;
tempRecordsetClass.Open(xmlStream, tempRecordsetClass.Source,
tempRecordsetClass.CursorType, tempRecordsetClass.LockType, (int)
ADODB.CommandTypeEnum.adCmdUnspecified);

rsNewWFC = (ADODB.RecordsetClass)rsEmptyAI;

// copy the unmodified recordset to the empty, then it will be in status
new
this.copyRecordData(rsUnmodifiedWFC, rsNewWFC);

rsNewAI.Source =((System.Object) rsNewWFC.DataSource);
}
catch (System.Exception t)
{
throw SPServerException.toServerException(t);
}

return rsNewAI;
}


.



Relevant Pages

  • Re: Database + dll
    ... You can include an XML or ADTG persisted Recordset with the ... XML can be compiled into a DLL as a resource, ... copied to a stream first anyway (not that the recordset would alter the ... It's a simple matter of creating a custom resource type from an XML file at ...
    (microsoft.public.vb.database.ado)
  • Re: Recordset load XML
    ... file, if you are using a version of ADO that supports the Stream object, you ... new Recordset ... Recordset return so I save the RecordSet to an XML string: ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Database + dll
    ... You can include an XML or ADTG persisted Recordset with the ... > copied to a stream first anyway (not that the recordset would alter the ... > It's a simple matter of creating a custom resource type from an XML file at ...
    (microsoft.public.vb.database.ado)
  • Re: Trouble recreating ADO recordset from XML
    ... I use rst->Save to persist the data into a _Stream object. ... Meant to add, when opening a recordset on a persisted source, those options ... have you looked at the XML? ...
    (microsoft.public.data.ado)
  • Re: How to Programmatically Export as XML & SXL
    ... Unfortunately, I've had precious little to do with XML in Access, so I'm ... you use the ADO Recordset object's Save ... >>Dim rs As ADODB.Recordset ... >>Dim strADTGFile As String ...
    (microsoft.public.access.externaldata)