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
二进制access数据库wordC#
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货