如何使用 OleDb 读取 Oracle 中的 CLOB 列?
我在 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:本例中使用的驱动程序是微软的驱动程序。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定是否可以将 CLOB 类型与 Microsoft OLEDB 驱动程序一起使用。
一定要用微软的吗?
您最好使用 Oracle Provider for OLE DB< /a> 或更好,只需使用 Oracle Data Provider for .NET (ODP.NET)。
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).