Write
FileStream fstr = File.openread (Tb_filepath. Text); The OpenRead function is used to open a read-only file, Openwrite writable
BinaryReader br = new BinaryReader (FSTR);
byte[] buffer = br. Readbytes ((int) fstr. Length);
String sql = string. Format ("INSERT into Nvduser_flt. File_source values (+, ', ',: cont, ' we ') ");
IDbConnection cnn = Dbfactorysingleton.getinstance (). Factory.getconnection ();
Cnn. Open ();
IDbCommand dbcom = Dbfactorysingleton.getinstance (). Factory.getcommand ();
Dbcom. Connection = CNN;
Dbcom.commandtext = SQL;
System.Data.IDataParameter mypara= dbfactorysingleton.getinstance (). Factory.getdataparameter ("cont", dbtype.binary);
Mypara. Value = buffer;
Dbcom. Parameters.Add (Mypara);
Dbcom. ExecuteNonQuery ();
Fstr. Close ();
Read
String sql = string. Format ("Select content from {0}.file_source where file_id={1}", Aislogical.dbuser,fid);
byte[] data = (byte[]) dbfactorysingleton.getinstance (). Factory.executescalar (SQL);
if (data! = NULL)
{
String EP = Application.executablepath;
EP = EP. Substring (0, Ep. LastIndexOf ("\ \") + 1);
Try
{
string[] FLs = Directory.GetFiles (EP, "Tmpsourcefile.*");
foreach (String fl in FLs)
File.delete (FL);
}
Catch {}
Try
{
String pf = EP + "Tmpsourcefile." +HZM;
FileStream stream = new FileStream (PF, filemode.createnew, FileAccess.Write);
BinaryWriter bw = new BinaryWriter (stream);
Bw. Write (data);
Bw. Close ();
Stream. Close ();
Thread.Sleep (100);
Process proc = new process ();
Proc. Startinfo.filename = PF;
Proc. Startinfo.arguments = "";
Proc. Start ();
}
Catch {}
}
CLOB, Blob is Oracle two special field type size limit are 4g,clob and blob is the difference is CLOB processing large string, and Blob is quite a sophomore binary file. Clob is similar to string comparisons in Oracle internal Dbms_lob, and is not described here.
Insert:
OracleParameter para = new OracleParameter ("cont", Oracletype.clob);
Para. Value = Xmlheader;
Cmd. Parameters.clear ();
Cmd. Parameters.Add (para);
Cmd.commandtext = "INSERT into Kmlview (name,content) VALUES (' Airport ',: cont)";
Cmd. ExecuteNonQuery ();
READ: No difference from reading a normal string
sql = string. Format ("Select content from {0}.kmlview where name= ' airport '", Aislogical.dbuser);
String data = Dbfactorysingleton.getinstance (). Factory.executescalar (SQL). ToString (). Trim ();
unless internal parsing is required, do not use CLOB , CLOB faster than BLOB Slow Speed the times more than
2015.1.5 Write, read binary fields with Dbfactorysingleton and Oralce clob type fields read and write [unless internal parsing is required, do not use clob,clob speed 15 times times slower than blobs]