2010-03-29 76 views
6

我已创建了这种结构Oracle 10g数据库上的表:如何使用OleDb读取Oracle中的CLOB列?

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:在这种情况下使用的驱动程序是Microsoft的驱动程序。

回答

5

我不确定有可能使用Microsoft OLEDB驱动程序的CLOB类型。

您是否必须使用Microsoft? 你会更好地使用Oracle Provider for OLE DB或更好,但只使用Oracle Data Provider for .NET(ODP.NET)。

+0

我已经能够使用Oracle ODP.NET驱动程序读取数据,但现有应用程序对每个连接使用OleDb。更改默认驱动程序需要一些代码迁移并在客户端上安装ODP.NET。这就是为什么我更喜欢坚持OleDb驱动。 – 2010-03-29 12:36:15

+1

我不知道这个Microsft知识库文章(http://support.microsoft.com/kb/244661)是否仍然适用,但它说'特定于Oracle 8.x的数据类型,如CLOB,BLOB,BFILE, NCHAR,NCLOB和NVARCHAR2不支持'。如果确实如此,我认为你的运气不佳:( – 2010-03-29 12:44:07

+0

另外,如果你还没有看过这个内容,请参考:http://groups.google.co.uk/group/borland.public.delphi.database .ado/browse_thread/thread/47674ad1a1e8ec75/228f9b4a22f5c9a5 – 2010-03-29 12:46:51