Search code examples
xmloledb

System.Data.OleDb.OleDbException when trying to load XML file via OLEDB


Error received:

Unrecognized database format 'C:\Documents and Settings\YepMyUserName\Local Settings\Temp\tmp1E1.tmp'. ---> System.Data.OleDb.OleDbException: Unrecognized database format 'C:\Documents and Settings\YepMyUserName\Local Settings\Temp\tmp1E1.tmp'..

Code:

using (OleDbConnection connection = new OleDbConnection(string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0}", filename)))
            {
                try
                {
                    connection.Open();
                    ....

Exception is thrown at connection.Open. I have only found one post on how to load XML file this way and apparently it didn't help.

Please help.


Solution

  • If you want to load XML into an ADO.Net dataset you can use the DataSet.ReadXxml() method, which will either take a file path or a stream/reader. You can provide it with XML schemas etc as well. There's more on this here.