BLOB storage ADO.NET

  • Thread starter Thread starter Bala Nagarajan
  • Start date Start date
B

Bala Nagarajan

Hello,
I am trying to store a binary file in a blob column of a oracle
table but i get the following exception " ORA-01460: unimplemented or
unreasonable conversion requested". Any insight as to why this may happen??
It seems to work fine if the data size is small (weird??). I am using .NET
1.1 and Systsem.Data.OracleClient to connect to Oracle 9.1.

Any thoughts??

Thanks
Bala
 
The database type should be "BLOB"…
In pseudo code are the blob write operations for Oracle.
If you have more questions, ask…

byte[] blobValue;
SelectString=String.Format("UPDATE {0} SET {1} = :blobdata {2}
",tableName,columnContainingBlobName,whereClause);

System.Data.OracleClient.OracleCommand Command =
Command.CommandText = SelectString;
Command.Connection = _Connection;
Command.Transaction = _Transaction;
Command.CommandTimeout=CommandTimeout;

System.Data.OracleClient.OracleParameter dataParameter;
dataParameter.ParameterName = "blobdata";
dataParameter.DbType = System.Data.DbType.Binary;
dataParameter.Direction=ParameterDirection.Input;
dataParameter.Value = blobValue;
dataParameter.Size=blobValue.Length;

Command.Parameters.Add(dataParameter);

Result=Command.ExecuteNonQuery();
 
Thanks for the response. But it does not seem to work. I am not able to
figure out what the problem could be.

Here is the code snippet i am using.

********************************************************
FileStream fs = new FileStream("myfile.dll",FileMode.Open,FileAccess.Read);

byte[] file = new byte[fs.length];

fs.Read(file,0,(int)file.Length);

fs.Close();

OracleConnection conn = new OracleConnection("connectionString");

OracleCommand cmd = conn.CreateCommand();

OracleParameter param5 = new OracleParameter("p_file",OracleType.Blob);

param5.Direction = ParameterDirection.Input;

param5.Value = file;

cmd.Paramaeters.Add(param5);

string qry = "ADDFILE";

cmd.CommandText = qry;

cmd.CommandType = CommandType.StoredProcedure;

conn.open();

cmd.ExecuteNonQuery();

conn.close();

********************************************************

Oracle stored procedure

//appfiles ia table with a blob column

procedure AddFile(,p_file in blob)
is
begin

insert into appfiles(ffile_obj)
values (p_file);

end AddFile;



********************************************************************



Thanks for the Help...

MrSmersh said:
The database type should be "BLOB".
In pseudo code are the blob write operations for Oracle.
If you have more questions, ask.

byte[] blobValue;
SelectString=String.Format("UPDATE {0} SET {1} = :blobdata {2}
",tableName,columnContainingBlobName,whereClause);

System.Data.OracleClient.OracleCommand Command =
Command.CommandText = SelectString;
Command.Connection = _Connection;
Command.Transaction = _Transaction;
Command.CommandTimeout=CommandTimeout;

System.Data.OracleClient.OracleParameter dataParameter;
dataParameter.ParameterName = "blobdata";
dataParameter.DbType = System.Data.DbType.Binary;
dataParameter.Direction=ParameterDirection.Input;
dataParameter.Value = blobValue;
dataParameter.Size=blobValue.Length;

Command.Parameters.Add(dataParameter);

Result=Command.ExecuteNonQuery();


Bala Nagarajan said:
Hello,
I am trying to store a binary file in a blob column of a oracle
table but i get the following exception " ORA-01460: unimplemented or
unreasonable conversion requested". Any insight as to why this may
happen??
It seems to work fine if the data size is small (weird??). I am using
.NET
1.1 and Systsem.Data.OracleClient to connect to Oracle 9.1.

Any thoughts??

Thanks
Bala
 
The SQL query sintax is important , the :blobdata ....
Also us the pseudo code... the command type is not stored procedure, and so on
Try in this manner and keep me posted.

Bala Nagarajan said:
Thanks for the response. But it does not seem to work. I am not able to
figure out what the problem could be.

Here is the code snippet i am using.

********************************************************
FileStream fs = new FileStream("myfile.dll",FileMode.Open,FileAccess.Read);

byte[] file = new byte[fs.length];

fs.Read(file,0,(int)file.Length);

fs.Close();

OracleConnection conn = new OracleConnection("connectionString");

OracleCommand cmd = conn.CreateCommand();

OracleParameter param5 = new OracleParameter("p_file",OracleType.Blob);

param5.Direction = ParameterDirection.Input;

param5.Value = file;

cmd.Paramaeters.Add(param5);

string qry = "ADDFILE";

cmd.CommandText = qry;

cmd.CommandType = CommandType.StoredProcedure;

conn.open();

cmd.ExecuteNonQuery();

conn.close();

********************************************************

Oracle stored procedure

//appfiles ia table with a blob column

procedure AddFile(,p_file in blob)
is
begin

insert into appfiles(ffile_obj)
values (p_file);

end AddFile;



********************************************************************



Thanks for the Help...

MrSmersh said:
The database type should be "BLOB".
In pseudo code are the blob write operations for Oracle.
If you have more questions, ask.

byte[] blobValue;
SelectString=String.Format("UPDATE {0} SET {1} = :blobdata {2}
",tableName,columnContainingBlobName,whereClause);

System.Data.OracleClient.OracleCommand Command =
Command.CommandText = SelectString;
Command.Connection = _Connection;
Command.Transaction = _Transaction;
Command.CommandTimeout=CommandTimeout;

System.Data.OracleClient.OracleParameter dataParameter;
dataParameter.ParameterName = "blobdata";
dataParameter.DbType = System.Data.DbType.Binary;
dataParameter.Direction=ParameterDirection.Input;
dataParameter.Value = blobValue;
dataParameter.Size=blobValue.Length;

Command.Parameters.Add(dataParameter);

Result=Command.ExecuteNonQuery();


Bala Nagarajan said:
Hello,
I am trying to store a binary file in a blob column of a oracle
table but i get the following exception " ORA-01460: unimplemented or
unreasonable conversion requested". Any insight as to why this may
happen??
It seems to work fine if the data size is small (weird??). I am using
.NET
1.1 and Systsem.Data.OracleClient to connect to Oracle 9.1.

Any thoughts??

Thanks
Bala
 
Thanks for responding. Inserting a blob value into the database never seems
to work for me. I am sure i ma using the correct syntax....I am using Oracle
9i and .NET 1.1...
ADO.NET gurus please help out!

Thanks
Bala
MrSmersh said:
The SQL query sintax is important , the :blobdata ....
Also us the pseudo code... the command type is not stored procedure, and
so on
Try in this manner and keep me posted.

Bala Nagarajan said:
Thanks for the response. But it does not seem to work. I am not able to
figure out what the problem could be.

Here is the code snippet i am using.

********************************************************
FileStream fs = new
FileStream("myfile.dll",FileMode.Open,FileAccess.Read);

byte[] file = new byte[fs.length];

fs.Read(file,0,(int)file.Length);

fs.Close();

OracleConnection conn = new OracleConnection("connectionString");

OracleCommand cmd = conn.CreateCommand();

OracleParameter param5 = new OracleParameter("p_file",OracleType.Blob);

param5.Direction = ParameterDirection.Input;

param5.Value = file;

cmd.Paramaeters.Add(param5);

string qry = "ADDFILE";

cmd.CommandText = qry;

cmd.CommandType = CommandType.StoredProcedure;

conn.open();

cmd.ExecuteNonQuery();

conn.close();

********************************************************

Oracle stored procedure

//appfiles ia table with a blob column

procedure AddFile(,p_file in blob)
is
begin

insert into appfiles(ffile_obj)
values (p_file);

end AddFile;



********************************************************************



Thanks for the Help...

MrSmersh said:
The database type should be "BLOB".
In pseudo code are the blob write operations for Oracle.
If you have more questions, ask.

byte[] blobValue;
SelectString=String.Format("UPDATE {0} SET {1} = :blobdata {2}
",tableName,columnContainingBlobName,whereClause);

System.Data.OracleClient.OracleCommand Command =
Command.CommandText = SelectString;
Command.Connection = _Connection;
Command.Transaction = _Transaction;
Command.CommandTimeout=CommandTimeout;

System.Data.OracleClient.OracleParameter dataParameter;
dataParameter.ParameterName = "blobdata";
dataParameter.DbType = System.Data.DbType.Binary;
dataParameter.Direction=ParameterDirection.Input;
dataParameter.Value = blobValue;
dataParameter.Size=blobValue.Length;

Command.Parameters.Add(dataParameter);

Result=Command.ExecuteNonQuery();


:

Hello,
I am trying to store a binary file in a blob column of a
oracle
table but i get the following exception " ORA-01460: unimplemented or
unreasonable conversion requested". Any insight as to why this may
happen??
It seems to work fine if the data size is small (weird??). I am using
.NET
1.1 and Systsem.Data.OracleClient to connect to Oracle 9.1.

Any thoughts??

Thanks
Bala
 
Thanks everyone. I was able to resolve the issue. For details please look at
the following knowledge base article.

http://support.microsoft.com/default.aspx?scid=kb;en-us;322796



Bala

Bala Nagarajan said:
Thanks for responding. Inserting a blob value into the database never
seems to work for me. I am sure i ma using the correct syntax....I am
using Oracle 9i and .NET 1.1...
ADO.NET gurus please help out!

Thanks
Bala
MrSmersh said:
The SQL query sintax is important , the :blobdata ....
Also us the pseudo code... the command type is not stored procedure, and
so on
Try in this manner and keep me posted.

Bala Nagarajan said:
Thanks for the response. But it does not seem to work. I am not able to
figure out what the problem could be.

Here is the code snippet i am using.

********************************************************
FileStream fs = new
FileStream("myfile.dll",FileMode.Open,FileAccess.Read);

byte[] file = new byte[fs.length];

fs.Read(file,0,(int)file.Length);

fs.Close();

OracleConnection conn = new OracleConnection("connectionString");

OracleCommand cmd = conn.CreateCommand();

OracleParameter param5 = new OracleParameter("p_file",OracleType.Blob);

param5.Direction = ParameterDirection.Input;

param5.Value = file;

cmd.Paramaeters.Add(param5);

string qry = "ADDFILE";

cmd.CommandText = qry;

cmd.CommandType = CommandType.StoredProcedure;

conn.open();

cmd.ExecuteNonQuery();

conn.close();

********************************************************

Oracle stored procedure

//appfiles ia table with a blob column

procedure AddFile(,p_file in blob)
is
begin

insert into appfiles(ffile_obj)
values (p_file);

end AddFile;



********************************************************************



Thanks for the Help...

The database type should be "BLOB".
In pseudo code are the blob write operations for Oracle.
If you have more questions, ask.

byte[] blobValue;
SelectString=String.Format("UPDATE {0} SET {1} = :blobdata {2}
",tableName,columnContainingBlobName,whereClause);

System.Data.OracleClient.OracleCommand Command =
Command.CommandText = SelectString;
Command.Connection = _Connection;
Command.Transaction = _Transaction;
Command.CommandTimeout=CommandTimeout;

System.Data.OracleClient.OracleParameter dataParameter;
dataParameter.ParameterName = "blobdata";
dataParameter.DbType = System.Data.DbType.Binary;
dataParameter.Direction=ParameterDirection.Input;
dataParameter.Value = blobValue;
dataParameter.Size=blobValue.Length;

Command.Parameters.Add(dataParameter);

Result=Command.ExecuteNonQuery();


:

Hello,
I am trying to store a binary file in a blob column of a
oracle
table but i get the following exception " ORA-01460: unimplemented or
unreasonable conversion requested". Any insight as to why this may
happen??
It seems to work fine if the data size is small (weird??). I am using
.NET
1.1 and Systsem.Data.OracleClient to connect to Oracle 9.1.

Any thoughts??

Thanks
Bala
 
Back
Top