hello,
im doing my first ASP.NET app that inserts & retrieves files from
Oracle (no need for a discussion on *that*!).
i learned first-hand of the somewhat awkward technique for inserting
binary data into an Oracle BLOB column via ADO.NET. since my files are
larger than 33k, it seemed had to use this technique:
http://support.microsoft.com/default...b;en-us;322796
....in which you fill an OracleLob object and pass it into your BLOB
column (via a proc in my case).
now i have to retrieve my blob file, and response it to the user. i
imagine the process is something like: 1) get data out of db, 2)
convert to working format 3) response to client.
however, im running into hitches. not sure what is wrong. can anyone
post snippets of working code for doing this? for retrieval, heres my
snippet:
//conn & command
OracleConnectio n conn = new
OracleConnectio n(Configuration Settings.AppSet tings["connStr"]);
OracleCommand command = new
OracleCommand(" COFE.GetInspect ionReportByID", conn);
command.Command Type = CommandType.Sto redProcedure;
//params
command.Paramet ers.Add("p_file ID", OracleType.Numb er).Value = reportID;
command.Paramet ers.Add("cur_re sults", OracleType.Curs or).Direction =
ParameterDirect ion.Output; //output
OracleLob blob = null;
//fill blob
conn.Open();
OracleDataReade r dr = command.Execute Reader();
if (dr.Read()) //has row
blob = dr.GetOracleLob (5);
byte[] byteArray = (byte[])blob.Value;
conn.Close();
//response (kitchen sink for tests)
Response.Clear( );
Response.ClearC ontent();
Response.ClearH eaders();
Response.Conten tType = "applicatio n/vnd.ms-excel";
Response.AddHea der("content-disposition", "attachment ; filename=" +
report.FileName );
Response.Buffer Output = true;
Response.Binary Write(byteArray );
Response.End();
....however, when excel loads the file, it says its an "unrecogniz able
format". opening it in notepad, its empty. *but*, right-clicking the
file, its size on disk matches the pre-databased version exactly!
any idea what im missing?
thanks!
matt