报表保存到数据库nvarchar(max)与读取
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.Value = wenben ;
}
2、读取报表文件
string strrpt=ds_Pub.Tables.Rows["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))
{
PageReportViewPgReport = new PageReport(StreamTxtRead);
ARptView.LoadDocument(ViewPgReport.Document);
}
老铁优秀!!!:hjyzw:
页:
[1]