0

We have our own DataAccess library built upon the Microsoft Enterprise Data Access block.

I have stored procedure that takes binary file content as input parameter and store it into DB.

byte[] imageFileByteArray = this.GetByteArrayFromFile(imageFile);
this.dataAccess.AddCmdParameter("DOCIMAGE", System.Data.DbType.Binary, imageFileByteArray);

This code is working fine when using SQL database, But when I switched to Oracle, I get the exception saying that "Wrong type of parameter"

In oracle db, the DOCIMAGE column is declared as BLOB field.

Why inferred Dbtype.Binary is not working for oracle?

vijay
  • 635
  • 2
  • 13
  • 26

2 Answers2

1

You will need to use an OracleParameter, with the OracleType enum value Blob, see here for more...

http://msdn.microsoft.com/en-us/library/system.data.oracleclient.oracletype.aspx

Justin Harvey
  • 14,446
  • 2
  • 27
  • 30
  • As i have mentioned, we are using our own DAL dll which doesn't accept explicit OracleType other than DbType. – vijay Oct 25 '12 at 12:18
0

This is probably to do with different Oracle inference of OracleDbType from System.Data.DbType. The System.Data.DbType.Binary has coresponding OracleDbType=Raw. You would have to use System.Data.DbType.Object to get OracleDbType=Blob, for more details see Table 3-3 in http://docs.oracle.com/html/B14164_01/featOraCommand.htm

Adrian Ciura
  • 1,102
  • 1
  • 9
  • 14
  • I tried, and I get this following error."Cannot bind type System.Byte[] as Blob." But in this [post](http://www.tek-tips.com/viewthread.cfm?qid=1399831) says, he got it working after changing it from DbType.Object to DbType.Binary. Either way it is not working for me. Any suggestions? – vijay Oct 25 '12 at 12:30