PRB: Error Occurs When You Open an ADO Recordset on an XML Stream
This article was previously published under Q259555 SYMPTOMS If you persist a Microsoft ActiveX Data Objects (ADO)
recordset into an external XML file, and you then load the XML file into an ADO
Stream object and open another ADO recordset on the ADO Stream object, the
following error messages occurs: Code = E_FAIL Source = Microsoft OLEDB Persistence Provider Description = Recordset cannot be created from the specified source. The source file or stream must contain Recordset data in XML or ADTG format. CAUSE When a recordset is saved to a file in an XML format, the
data written to the file by the Microsoft Persistence Provider is in the UTF-8 encoding charset. However, the default character set of an ADO Stream object is Unicode (UTF-16) with byte order mark 0xFFFE. So, when the UTF-8 format file is loaded into the ADO stream, the internal buffer of the ADO stream contains the UTF-8 data but the data is prepended with 0xFFFE Unicode byte order marks. This causes the XML parser to fail, and the XML parser does not process the data when the ADO stream is used to open a recordset. If the recordset is saved to a Stream in XML format, the data written to the stream is in Unicode encoding charset, that is, UTF-16, which is the same as the default encoding used for an ADO stream. RESOLUTION Here are two ways you can work around this problem:
STATUS This behavior is by design. MORE INFORMATION The following code demonstrates the problem. If the
following code line is uncommented, the code runs without error: Note You may need to change the connection string to reflect your
data source.Note You must change uid=<username> and pwd=<strong password> to the correct values before you run this code. Make sure that uid has the appropriate permissions to perform this operation on the database. Sample Code NOTE: You may notice that if you specify other charsets such as "iso-8859-1" also works around the problem. For example: This is because there is no 0xFFFE Unicode byte order marks prepended
to your data when you load the XML file into the ADO Stream object.
REFERENCES For more information, see the MSDN Library documentation
about the ADO Stream object, and the Charset property of the object. The Stream
object is available in ADO 2.5 and later. APPLIES TO
| Article Translations
|

Back to the top
