新建保存数据的oracle数据表:
CREATE TABLE "FILE_DB"
( "FILEID" VARCHAR2(20 BYTE),
"FILENAME" VARCHAR2(100 BYTE),
"FILEBLOB" BLOB
)
//下面是把文件保存进oracle的代码
//把文件到数据库
public void SaveFiletoDB(string filename)
{
OracleConnection ocn = new OracleConnection(“连接字符");
ocn.Open();
string sql = "insert into FILE_DB (FILEID,FILENAME,FILEBLOB) values (:FILEID,:FILENAME,:FILEBLOB)" ;
OracleCommand cmd = new OracleCommand(sql, ocn);
FileStream fs = File.OpenRead(filename);
byte[] b = new byte[fs.Length];
fs.Read(b, 0, b.Length);
fs.Close();