如何使用 OleDb 读取 Oracle 中的 CLOB 列?

2024-01-13

我在 Oracle 10g 数据库上创建了一个具有以下结构的表:

create table myTable
(
id       number(32,0)      primary key,
myData   clob
)

我可以毫无问题地在表中插入行,但是当我尝试使用 OleDb 连接从表中读取数据时,出现异常。

这是我使用的代码:

using (OleDbConnection dbConnection = new OleDbConnection("ConnectionString"))
{
    dbConnection.Open();

    OleDbCommand dbCommand = dbConnection.CreateCommand();

    dbCommand.CommandText = "SELECT * FROM myTable WHERE id=?";
    dbCommand.Parameters.AddWithValue("ID", id);

    OleDbDataReader dbReader = dbCommand.ExecuteReader();
}

异常详细信息似乎指向不受支持的数据类型:

System.Data.OleDb.OleDbException: 
Unspecified error Oracle error occurred, but error message could not be retrieved from Oracle. 
Data type is not supported.

有谁知道如何使用 OleDb 连接读取这些数据?

PS:本例中使用的驱动程序是微软的驱动程序。


我不确定是否可以将 CLOB 类型与 Microsoft OLEDB 驱动程序一起使用。

一定要用微软的吗? 你会更好地使用OLE DB 的 Oracle 提供程序 http://www.oracle.com/technology/software/tech/windows/ole_db/index.html或者更好,只需使用适用于 .NET 的 Oracle 数据提供程序 http://www.oracle.com/technology/tech/windows/odpnet/index.html(ODP.NET)。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何使用 OleDb 读取 Oracle 中的 CLOB 列? 的相关文章

随机推荐