将word以二进制文件保存到access数据库时,较大文件用时较长的问题应该怎样解决?怎样做可以快一点儿?请高手帮忙!多谢!!

志在千里 志在千里 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

string[] sSpilt = resultFile.Split('\\');
int icount = sSpilt.Length;
sSplitPath = sSpilt[icount - 1];


#region 将word内容保存到数据库
OleDbConnection cn = new OleDbConnection(StartWindow.StrConn);
FileInfo fi = new FileInfo(resultFile);
FileStream fs = fi.OpenRead();
if (fs.Length < 20971520)
{
if (resultFile != "")
{
linkLabelEBidBook.Text = sSplitPath;
linkLabelEBidBook.Visible = true;
byte[] bytes = new byte[fs.Length];
fs.Read(bytes, 0, Convert.ToInt32(fs.Length));
OleDbCommand cm = new OleDbCommand();

//OleDbDataAdapter da = new OleDbDataAdapter(@"select * from Base_BusinessSection", cn);
//DataSet ds = new DataSet(); //创建DataSet对象
//da.Fill(ds); //用OleDbDataAdapter对象da填充、更新刚创建的DataSet对象
cm.Connection = cn;
cm.CommandType = CommandType.Text;
if (cn.State == 0) cn.Open();
string ebooksql = "select * from EBidBook";
cm = new OleDbCommand(ebooksql, cn);
DataSet dsebook = new DataSet();
OleDbDataAdapter mycommand = new OleDbDataAdapter(ebooksql, cn);
mycommand.Fill(dsebook, "ebook");
mycommand.Dispose();
int sizebook = dsebook.Tables["ebook"].Rows.Count;


//cm = new OleDbCommand("insert into [EBidBook](EBookFileName)values('sr')", cn);
//cm.ExecuteNonQuery();
cm.CommandText = "update EBidBook set EBidBookOLE=@file ,EBookFileName='" + sSplitPath + "'";
OleDbParameter spFile = new OleDbParameter("@file", OleDbType.LongVarBinary);
spFile.Value = bytes;
cm.Parameters.Add(spFile);
cm.ExecuteNonQuery();//如果是大的文件到这个地方就卡住就像死机一样等老长时间才能执行完,请高手帮忙?
cn.Close();

#endregion
...全文
评论 3
收藏 已收藏
分享
返回顶部
志在千里
C# 111,130 成员 642,540 内容