L
Lauchlan M
Hi
I want to upload a general BLOB (jpg, doc, pdf etc) to the database.
My code for this is at the moment something like
<<
if (
(fileDischargeFile.PostedFile != null) // there is an uplaoded file
& (fileDischargeFile.PostedFile.ContentLength !=0 ) ) // of non-zero
length
{
//Get the posted file
System.IO.Stream fileDataStream =
fileDischargeFile.PostedFile.InputStream;
//Get length of file
int fileLength = fileDischargeFile.PostedFile.ContentLength;
//Create a byte array with file length
byte[] fileData = new byte[fileLength];
//Read the stream into the byte array
fileDataStream.Read(fileData,0,fileLength);
lblUploadMessage.Text = fileData.Length.ToString(); // check we got
it - testing only - (*)
// load up the data reader so we can write the file into the BLOB
field:
nxCommand_UpdateDischargeFile.Parameters["SessionID"].Value =
Request.QueryString["SessionDataID"];
nxCommand_UpdateDischargeFile.Parameters["DischargeSummaryAmendment"].Value
= fileData;
nxConnection.Open();
nxCommand_UpdateDischargeFile.ExecuteNonQuery();
nxConnection.Close();
What happens is that it all appears to work, it tells me it's uploaded file
of say 25,321 bytes (in line *, above), but when I have a look at the BLOB
in the database there appears to be nothing there.
Is the above correct, andd is it the best way to generally load a BLOB into
the database?
Thanks!
Lauchlan M
I want to upload a general BLOB (jpg, doc, pdf etc) to the database.
My code for this is at the moment something like
<<
if (
(fileDischargeFile.PostedFile != null) // there is an uplaoded file
& (fileDischargeFile.PostedFile.ContentLength !=0 ) ) // of non-zero
length
{
//Get the posted file
System.IO.Stream fileDataStream =
fileDischargeFile.PostedFile.InputStream;
//Get length of file
int fileLength = fileDischargeFile.PostedFile.ContentLength;
//Create a byte array with file length
byte[] fileData = new byte[fileLength];
//Read the stream into the byte array
fileDataStream.Read(fileData,0,fileLength);
lblUploadMessage.Text = fileData.Length.ToString(); // check we got
it - testing only - (*)
// load up the data reader so we can write the file into the BLOB
field:
nxCommand_UpdateDischargeFile.Parameters["SessionID"].Value =
Request.QueryString["SessionDataID"];
nxCommand_UpdateDischargeFile.Parameters["DischargeSummaryAmendment"].Value
= fileData;
nxConnection.Open();
nxCommand_UpdateDischargeFile.ExecuteNonQuery();
nxConnection.Close();
What happens is that it all appears to work, it tells me it's uploaded file
of say 25,321 bytes (in line *, above), but when I have a look at the BLOB
in the database there appears to be nothing there.
Is the above correct, andd is it the best way to generally load a BLOB into
the database?
Thanks!
Lauchlan M