4,816
社区成员
发帖
与我相关
我的任务
分享
protected void Page_Init(object sender, EventArgs e)
{
DataSet ds = new DataSet();
OracleConnection Con = new OracleConnection(Con_str);
string strSQL = "select * from bfc_zlpic";
OracleDataAdapter da = new OracleDataAdapter(strSQL, Con);
da.Fill(ds);
DataSet1 myDataSet = new Dataset1();
FileStream fs;
BinaryReader br;
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
string _ywid = Convert.ToString(ds.Tables[0].Rows[i]["ywid"]);
int _tpzl = Convert.ToInt32(ds.Tables[0].Rows[i]["tpzl"]);
string _cphm = Convert.ToString(ds.Tables[0].Rows[i]["cphm"]);
string _hpzl = Convert.ToString(ds.Tables[0].Rows[i]["hpzl"]);
string _tplj = Convert.ToString(ds.Tables[0].Rows[i]["tplj"]);
if (_tplj.Length != 0)
{
fs = new FileStream(_tplj, FileMode.Open);
br = new BinaryReader(fs);
byte[] pictureData = br.ReadBytes((int)br.BaseStream.Length);
AddOneRow(myDataSet, _ywid, _tpzl, _cphm, _hpzl, pictureData);
}
else
{
AddOneRow(myDataSet, _ywid, _tpzl, _cphm, _hpzl, null);
}
}
if (Session["myRpt"] != null)
{
CrystalReportViewer1.ReportSource = (ReportDocument)Cache["myRpt"];
}
else
{
ReportDocument myReport = new ReportDocument();
myReport.Load(Server.MapPath("CrystalReport1.rpt"));
myReport.SetDataSource(myDataSet);
CrystalReportViewer1.ReportSource = myReport;
Cache["myRpt"] = myReport;
}
}
public void AddOneRow(DataSet1 ds,string ywid,int tpzl,string cphm,string hpzl,byte[] tplj)
{
ds.myTable.AddmyTableRow(ywid, tpzl, cphm, hpzl, tpzl);
}