二进制流分步写入数据库实现(SPS中实现)

先利用WSS的接口,添加文档doc

//SqlConnection cn=new SqlConnection(ConfigurationSettings.AppSettings["Sps_SITE"].ToString());
//cn.Open();
//SqlCommand cmd=cn.CreateCommand();
//doc = folder.AddDocument(fileName, new byte[0], false);
//try
//{
//doc.ID = Convert.ToInt32(doc.SPFile.Item["ID"]);
////改变大小
//cmd.CommandText="update docs set Size="+FileSize.ToString()+" where DoclibRowId="+doc.ID+" and listid='"+docLibGuid+"' ";
//cmd.ExecuteNonQuery();
//
//cmd.CommandText="declare @content varbinary(16) "
//+" select @content=textptr(content) from docs where DoclibRowId="+doc.ID+" and listid='"+docLibGuid+"' "
//+" updatetext docs.content @content @length 0 @block";
//cmd.Parameters.Add("@block",System.Data.SqlDbType.Image);
//cmd.Parameters.Add("@length",System.Data.SqlDbType.Int);
//int len=8040000;
//byte[] DoubleBuffer = new byte[len];
//int iRead = 0;
//while (iRead<FileSize)
//{
//SingleFile.InputStream.Read(DoubleBuffer,0,len);
//cmd.Parameters["@block"].Value=DoubleBuffer;
//cmd.Parameters["@length"].Value=iRead;
//cmd.ExecuteNonQuery();
//iRead += len;
//}
//}
//catch (Exception ex)
//{
//folder.DeleteDocument(fileName);
//throw ex;
//}
//finally
//{
//cn.Close();
//cn.Dispose();
//}

你可能感兴趣的:(数据库)