FileStream fls;
fls = new FileStream(FileUpload1.PostedFile.FileName, FileMode.Open, FileAccess.Read);
byte[] blob = new byte[fls.Length];
fls.Read(blob, 0, System.Convert.ToInt32(fls.Length));
fls.Close();
con.Open();
string query = "insert into sample_file values(" + imageid.Text + "," + "'" + imagename.Text + "'," + " :BlobParameter )";
//insert the byte as oracle parameter of type blob
OracleCommand cmd;
OracleParameter blobParameter = new OracleParameter();
blobParameter.OracleType = OracleType.Blob;
blobParameter.ParameterName = "BlobParameter";
blobParameter.Value = blob;
cmd = new OracleCommand(query, con);
cmd.Parameters.Add(blobParameter);
cmd.ExecuteNonQuery();
con.Close();
Using.System.IO; //use this name space
Subscribe to:
Post Comments (Atom)

0 comments:
Post a Comment