Freshly released code
Private Boolean importgatherfile (string blobfilefolder, string xqdm, string xqmc)
{
Try
{
System. Io. filestream FS = NULL;
String [] blobfiles = directory. getfiles (blobfilefolder );
If (blobfiles. Length = 0)
Return false;
For (INT I = 0; I <blobfiles. length; I ++)
{
// File stream
String ppath = blobfiles [I];
FS = new system. Io. filestream (ppath, filemode. Open, fileaccess. Read );
Byte [] blob = new byte [fs. Length];
FS. Read (blob, 0, blob. Length );
FS. Close ();
// Maximum ID
Int intmaxoid = getmaxoid ("tablea", "f_oid ");
// Obtain the current age
String stryear = datetime. Now. year. tostring (). substring (0, 4 );
// File name
String pfilename;
Pfilename = ppath. substring (ppath. lastindexof ("//") + 1 );
Oracleparameter Param = NULL;
Oraclecommand cmd = NULL;
Cmd = mpropconnection. createcommand (); // mpropconnection is a variable of the oracleconnection type.
Cmd. commandtext = "insert into tablea (f_oid, f_xzqhdm, f_xzqhmc, f_filename, f_file, f_year) values (" + intmaxoid + ", '" + xqdm + "', '"+ xqmc +"', '"+ pfilename +"',: Doc, '"+ stryear + "')";
Param = new oracleparameter ("Doc", oracletype. Blob, blob. length, parameterdirection. Input, false, 0, 0, null, datarowversion. Current, blob );
Cmd. Parameters. Add (PARAM );
Cmd. executenonquery ();
}
Return true;
}
Catch (exception ex)
{
Return false;
}
}
Notes
1. filestream code for reading files;
2. Command variable (CMD) parameter "; Doc" is used in Oracle: @ should be used in SQL database @;
3. In the command parameter variable (PARAM), only "Doc" is used for the parameter without the colon. As to whether to use @ in SQL, the code to be viewed at night seems to need to be added
4. the type of the command parameter variable (PARAM). oracletype. Blob indicates the inserted type. I tried to use the oledb connection to complete this function. Unfortunately, I did not find a proper insertion type.