How to read a CLOB column in Oracle using OleDb?

北慕城南 提交于 2019-12-07 03:37:22

问题


I have created a table on an Oracle 10g database with this structure :

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

I can insert rows in the table without any problem, but when I try to read data from the table using OleDb connection, I get an exception.

Here is the code I use :

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();
}

The exception details seems to point on an unsupported data type :

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

Does anyone know how I can read this data using the OleDb connection ?

PS : The driver used in this case is the Microsoft one.


回答1:


I'm not sure it is possible to use the CLOB type with the Microsoft OLEDB driver.

Do you have to use the Microsoft one? You would be much better to use the Oracle Provider for OLE DB or better yet just use Oracle Data Provider for .NET (ODP.NET).



来源:https://stackoverflow.com/questions/2537613/how-to-read-a-clob-column-in-oracle-using-oledb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!