Victor Santos
Victor Santos

Reputation: 350

Map Oracle blob data to dataset direct

I have a table with a blob field that stores photos in jpg format.

Is there any way to direct fill the Dataset with the OracleDataAdapter?

Like:

My code in vb.net

Dim oAdp As OracleDataAdapter
Dim v_oDs As DsSubRegistro <- My Dataset

oAdp = New OracleDataAdapter(myConnection.sqlCmd("SELECT * FROM ..."))
With oAdp.TableMappings.Add(Common.DbDataAdapter.DefaultSourceTableName, v_oDs.Foto.TableName).ColumnMappings
    .Add("NU_ANO", "NU_ANO")
    .Add("NU_PID", "NU_PID")
    .Add("NU_RIC", "NU_RIC")
    .Add("NU_VIAS", "NU_VIAS")
    .Add("IM_FOTO", "IM_FOTO") <-- My blob field
End With

When I use the code above I get the error: Inconvertible type mismatch between SourceColumn 'IM_FOTO' of Byte[] and the DataColumn 'IM_FOTO' of Byte.

v_oDs.Foto.TableName, Foto is my Datatable.

IM_FOTO on my dataset use System.Byte DataType.

Thank you.

Upvotes: 0

Views: 1053

Answers (1)

competent_tech
competent_tech

Reputation: 44931

IM_FOTO on your dataset needs to be a byte array (System.Byte()) to hold the blob contents, but you only have it declared as a single Byte.

Upvotes: 1

Related Questions