Upload file to Oracle Database

xiaoxiao2021-03-06  55

Create a table named TestfileUpload under the HR scheme of the database, including 3 columns: primary key PKID, file name filename, file file (BLOB type).

Void UploadFile ()

{

FileStream objfs = new filestream (file1.value, filemode.open, fileaccess.read); binaryReader objbr = new binaryreader (OBJFS);

Byte [] ByTfile = Objbr.Readbytes ((int) objfs.length);

objOconn.Open ();; OracleCommand objOcmd = new OracleCommand (); objOcmd.Connection = objOconn; objOcmd.CommandText = "INSERT INTO OracleConnection objOconn = new ("; Data Source = tsems; password = system user id = system ") OracleConnection Hr.TestFileUpload Values ​​(: vfile,: vFileName,: vfile "; objocmd.parameters.add (" vpkid ", oracletype.varchar); objocmd.parameters [" vpkid "]. Value =" 2006 "; objocmd.parameters. Add ("vFileName", ORACLETY.VARCHAR); Objocmd.Parameters ["vFileName"]. Value = path.getFileName (file1.value); Objocmd.Parameters.add ("vfile", oracletype.blob, bytfile.length); Objocmd.Parameters ["VFILE"]. value = bytfile; objocmd.executenonquery (); objoconn.close (); response.write ("true");

}

转载请注明原文地址:https://www.9cbs.com/read-114306.html

New Post(0)