尝试通过OLEDB加载XML文件时System.Data.OleDb.OleDbException

时间:2022-09-27 10:41:46

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'..

无法识别的数据库格式'C:\ Documents and Settings \ YepMyUserName \ Local Settings \ Temp \ tmp1E1.tmp'。 ---> System.Data.OleDb.OleDbException:无法识别的数据库格式'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.

在connection.Open上抛出异常。我只发现了一篇关于如何以这种方式加载XML文件的帖子,显然它没有帮助。

Please help.

请帮忙。

1 个解决方案

#1


1  

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.

如果要将XML加载到ADO.Net数据集中,可以使用DataSet.ReadXxml()方法,该方法将采用文件路径或流/读取器。您也可以为它提供XML模式等。这里还有更多内容。

#1


1  

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.

如果要将XML加载到ADO.Net数据集中,可以使用DataSet.ReadXxml()方法,该方法将采用文件路径或流/读取器。您也可以为它提供XML模式等。这里还有更多内容。