sql保存字段类型nvarchar(max)
1、保存文件到数据库
using (TextReader StreamTxtRead = new StreamReader("报表文件路径"))
{
PageReport PgReport = new PageReport(StreamTxtRead);
string wenben = PgReport.ToRdlString();
SqlParameter[] pars = new SqlParameter[]{
new SqlParameter("@pbstream",SqlDbType.Nvarchar,-1)
};
pars[0].Value = wenben ;
}
2、读取报表文件
string strrpt=ds_Pub.Tables[0].Rows[0]["FPbStream"].ToString();
MemoryStream ms_pub = new MemoryStream();
byte[] byte_pub = System.Text.Encoding.UTF8.GetBytes(wenben);
ms_pub.Write(byte_pub, 0, byte_pub.Length);
ms_pub.Seek(0, SeekOrigin.Begin);
using (TextReader StreamTxtRead = new StreamReader(ms_pub))
{
PageReport ViewPgReport = new PageReport(StreamTxtRead);
ARptView.LoadDocument(ViewPgReport.Document);
}
|