日期:2014-05-20 浏览次数:20745 次
protected void Page_Load(object sender, EventArgs e) { string cmdtxt = "select * from customers where name='" + Session["newname"].ToString() + "'and ID ='" + Session["newidno"].ToString() + "'"; DataSet reportDs = Data.GetDs(cmdtxt); string path = 。。。; FileStream fs = new FileStream(path,FileMode.Open,FileAccess.Read); BinaryReader br = new BinaryReader(fs); byte[] bt = br.ReadBytes((int)fs.Length); fs.Close(); reportDs.Tables.Add("picture"); reportDs.Tables["picture"].Columns.Add("pic", System.Type.GetType("System.Byte[]")); DataRow row = reportDs.Tables["picture"].NewRow(); row[0] = bt; reportDs.Tables["picture"].Rows.Add(row); report.Load(Server.MapPath("~/CrystalReport.rpt")); report.SetDataSource(reportDs); CrystalReportViewer1.ReportSource = report;}