无法使用 OleDbDataReader 读取类型 blob
Cannot read type blob using OleDbDataReader
我正在尝试使用 OleDbConnection 从 oracle 数据库中检索 blob 数据,但它返回此错误 "Unspecified error, Oracle error occurred, but error message could not be retrieved from Oracle.Data type is not supported." 除了 blob,我通常可以检索其他类型(varchar、number...)的字段。感谢任何帮助,下面是我的代码:
Dim PictureCol As Integer = 0
Dim DestFilePath = "C:\testBlob.dat"
Dim Conn As New OleDbConnection
Conn.ConnectionString = GetConnectionString()
Conn.Open()
Dim cmd As New OleDbCommand("SELECT d.document_file from library_documents d d.CATEGORY_ID=1 ", Conn)
Dim dr As OleDbDataReader = cmd.ExecuteReader
dr.Read()
Dim b(dr.GetBytes(PictureCol, 0, Nothing, 0, Integer.MaxValue) - 1) As Byte
dr.GetBytes(PictureCol, 0, b, 0, b.Length)
dr.Close()
Conn.Close()
Dim fs As New System.IO.FileStream(DestFilePath, IO.FileMode.Create, IO.FileAccess.Write)
fs.Write(b, 0, b.Length)
fs.Close()
通过使用 oraclecommand 而不是 OleDB 解决
我正在尝试使用 OleDbConnection 从 oracle 数据库中检索 blob 数据,但它返回此错误 "Unspecified error, Oracle error occurred, but error message could not be retrieved from Oracle.Data type is not supported." 除了 blob,我通常可以检索其他类型(varchar、number...)的字段。感谢任何帮助,下面是我的代码:
Dim PictureCol As Integer = 0
Dim DestFilePath = "C:\testBlob.dat"
Dim Conn As New OleDbConnection
Conn.ConnectionString = GetConnectionString()
Conn.Open()
Dim cmd As New OleDbCommand("SELECT d.document_file from library_documents d d.CATEGORY_ID=1 ", Conn)
Dim dr As OleDbDataReader = cmd.ExecuteReader
dr.Read()
Dim b(dr.GetBytes(PictureCol, 0, Nothing, 0, Integer.MaxValue) - 1) As Byte
dr.GetBytes(PictureCol, 0, b, 0, b.Length)
dr.Close()
Conn.Close()
Dim fs As New System.IO.FileStream(DestFilePath, IO.FileMode.Create, IO.FileAccess.Write)
fs.Write(b, 0, b.Length)
fs.Close()
通过使用 oraclecommand 而不是 OleDB 解决