Everytime I try to inset a blob from a file I get the following error.
ORA-12571: TNS:packet writer failure.
I was able to successful insert a blob from a post to another another
page using the PostedFile object. But for some reason this will not
work for a file.
Below is the code that I tried:
// provide read access to the file
FileStream fs = new FileStream(newFileName,
FileMode.Open,FileAccess.Read);
// Create a byte array of file stream length
byte[] newFileBuf = new byte[fs.Length];
fs.Read(newFileBuf,0,System.Convert.ToInt32(fs.Len gth));
//Close the File Stream
fs.Close();
try
{
OleDbConnection cn = new OleDbConnection(strConnect);
OleDbCommand cmd = new OleDbCommand("INSERT INTO TESTBLOB
(NewFile,ID) VALUES (?, 1)", cn);
OleDbParameter prm1 = new OleDbParameter("@NewFile",
OleDbType.LongVarBinary, newFileBuf.Length, ParameterDirection.Input,
false, 0, 0,null, DataRowVersion.Current, newFileBuf);
cmd.Parameters.Add(prm1);
cn.Open();
cmd.ExecuteNonQuery();
cn.Close();
}
catch(Exception ex)
{
label1.Text = ex.Message;
}
when I use replace the top with this:
Stream myStream = Invoice.PostedFile.InputStream;
byte[] newFileBuf= new byte[Invoice.PostedFile.ContentLength];
myStream.Read(newFileBuf, 0, Invoice.PostedFile.ContentLength);