|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
problem writing blob to oraclei have a problem writing a blob to oracle using ado.net. maybe someone can help. here's my code: OleDbConnection con = new OleDbConnection("Provider=msdaora;Data Source=orcl;User Id=******;Password=******;"); try { con.Open(); string save_blob = "INSERT INTO blobtable " + "(id,content) " + "VALUES " + "(1,:contentParam)"; OleDbParameter contentParameter = new OleDbParameter(); contentParameter.OleDbType = OleDbType.LongVarBinary; contentParameter.ParameterName = "contentParam"; contentParameter.Value = this.content; // where content is an array of byte OleDbCommand command = new OleDbCommand(save_blob, con); command.Parameters.Add(contentParameter); command.ExecuteNonQuery(); command.Dispose(); } catch (Exception ex) { System.Diagnostics.Debug.Write("DATABASE ERROR:" + ex); } finally { con.Close(); } now everytime i try and run that code i get the following error: A first chance exception of type 'System.Data.OleDb.OleDbException' occurred in System.Data.dll DATABASE ERROR:System.Data.OleDb.OleDbException: ORA-01008: not all variables bound any ideas? Instead of using the OleDbConnection, get the OracleDataAdapter from
Oracle. It works great. because it is native for Oracle. And you'll also want to use a variable of type OracleClient.OracleLob. I did this a while back in VB.net, but the principle is the same. The Oracle documentation should have whatever else you need. Tom Achim Kuehn wrote: Show quote >hi, > >i have a problem writing a blob to oracle using ado.net. maybe someone can >help. >here's my code: > >OleDbConnection con = new OleDbConnection("Provider=msdaora;Data >Source=orcl;User Id=******;Password=******;"); >try >{ >con.Open(); >string save_blob = "INSERT INTO blobtable " >+ "(id,content) " >+ "VALUES " >+ "(1,:contentParam)"; > >OleDbParameter contentParameter = new OleDbParameter(); >contentParameter.OleDbType = OleDbType.LongVarBinary; >contentParameter.ParameterName = "contentParam"; >contentParameter.Value = this.content; // where content is an array of byte >OleDbCommand command = new OleDbCommand(save_blob, con); >command.Parameters.Add(contentParameter); >command.ExecuteNonQuery(); >command.Dispose(); >} >catch (Exception ex) >{ >System.Diagnostics.Debug.Write("DATABASE ERROR:" + ex); >} >finally >{ >con.Close(); >} > > >now everytime i try and run that code i get the following error: >A first chance exception of type 'System.Data.OleDb.OleDbException' occurred >in System.Data.dll >DATABASE ERROR:System.Data.OleDb.OleDbException: ORA-01008: not all >variables bound >any ideas? > > > > |
|||||||||||||||||||||||