owc图片文件改变,页面图片不会变
protected void ss_Click(object sender, EventArgs e)
{
System.IO.File.Delete(MapPath("./ShowData1.gif"));
string tj1 = BeginTime.Text.Trim();
string tj2 = EndTime.Text.Trim();
string tj3 = xq_name.Text.Trim();
string tj4;
//File.Delete(MapPath("文件路径"))
//string deleteFileName = "./ShowData.gif";
if (tj1 != "" && tj2 != "" && tj3 != "")
{
string strSeriesName = "图例";
string ConnectString = "server=10.81.198.238;uid=gaohanying;pwd=123456;database=master";
//string Sqk = "select wd_id from wdyl_chazhibiao where xq_name='+tj3+'";
string Sqk = "SELECT wd_id FROM wdyl_chazhibiao WHERE xq_name = '" + tj3 + "'";
//string Sql = "select wendu1 ,riqi from shishi3 where riqi>='" + tj1 + "'and riqi<='" + tj2 + "'";
SqlConnection myConn = new SqlConnection(ConnectString);
myConn.Open();
SqlCommand cmd = new SqlCommand(Sqk, myConn);
SqlDataReader dr = cmd.ExecuteReader();
DataSet ds = new DataSet();
if (dr.Read())
{
}
tj4 = dr["wd_id"].ToString();
string Sql = "select "+tj4+",riqi from shishi3 where riqi>='" + tj1 + "'and riqi<='" + tj2 + "'";
dr.Close();//关闭
dr.Dispose();//释放
SqlDataAdapter Da = new SqlDataAdapter(Sql, myConn);
Da.Fill(ds);
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();
GridView1.Visible = true;
//存放月
string[] MonNum = new string[300];
//存放数据
string[] MonCount = new string[300];
//为数组赋值
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
MonCount[i] = ds.Tables[0].Rows[i][0].ToString();
MonNum[i] = ds.Tables[0].Rows[i][1].ToString();
}
//为x轴指定特定字符串,以便显示数据(月份)
string strXdata = string.Empty;
foreach (string strData in MonNum)
{
strXdata += strData + "\t";
}
//为y轴指定特定字符串
string strYdata = string.Empty;
foreach (string strValue in MonCount)
{
strYdata += strValue + "\t";
}
//创建对象放置图表
ChartSpace laySpace = new ChartSpaceClass();
//在chartspace对象中添加图表
ChChart InsertChart = laySpace.Charts.Add(0);
//指定绘制图表的类型。类型可以通过OWC.ChartChartTypeEnum枚举值得到
//InsertChart.Type = ChartChartTypeEnum.chChartTypePie; //饼图
InsertChart.Type = ChartChartTypeEnum.chChartTypeLine;//折线图
//InsertChart.Type = ChartChartTypeEnum.chChartTypeArea;//面积图
//InsertChart.Type = ChartChartTypeEnum.chChartTypeBarClustered;//条形图
//InsertChart.Type = ChartChartTypeEnum.chChartTypeColumnClustered;//柱形图
//指定图表是否需要图例标注
InsertChart.HasLegend = false;
InsertChart.HasTitle = true;//为图表添加标题
InsertChart.Title.Caption = "温度变化曲线";//标题名称
//为x,y轴添加图示说明
InsertChart.Axes[0].HasTitle = true;
InsertChart.Axes[0].Title.Caption = "时间";
InsertChart.Axes[1].HasTitle = true;
InsertChart.Axes[1].Title.Caption = "温度";
InsertChart.SeriesCollection.Add(0);
//给定一个series系列的名字
//InsertChart.SeriesCollection[0].SetData(ChartDimensionsEnum.chDimSeriesNames, +(int)ChartSpecialDataSourcesEnum.chDataLiteral, strSeriesName);
//InsertChart.SeriesCollection[0].SetData(ChartDimensionsEnum.chDimSeriesNames, +(int)ChartSpecialDataSourcesEnum.chDataLiteral, strSeriesName);
InsertChart.SeriesCollection[0].SetData(ChartDimensionsEnum.chDimSeriesNames, +(int)ChartSpecialDataSourcesEnum.chDataLiteral, strSeriesName);
//mychart.SeriesCollection[0].SetData(ChartDimensionsEnum.chDimCategories,(int)ChartSpecialDataSourcesEnum.chDataLiteral, strDataName);
//给定分类
InsertChart.SeriesCollection[0].SetData(ChartDimensionsEnum.chDimCategories, +(int)ChartSpecialDataSourcesEnum.chDataLiteral, strXdata);
//给定值
InsertChart.SeriesCollection[0].SetData(ChartDimensionsEnum.chDimValues, (int)ChartSpecialDataSourcesEnum.chDataLiteral, strYdata);
//输出文件
string strAbsolutePath = (Server.MapPath(".")) + "\\ShowData1.gif";
laySpace.ExportPicture(strAbsolutePath, "GIF", 600, 450);
//创建GIF文件的相对路径
string strRelativePath = "./ShowData1.gif";
//把图片添加到placeholder中,并在页面上显示
string strImageTag = "<IMG SRC='" + strRelativePath + "'/>";
this.PlaceHolder1.Controls.Add(new LiteralControl(strImageTag));
}
vs中测试正常放到iis中就不正常了
开始以为是图片没更新加了 System.IO.File.Delete(MapPath("./ShowData1.gif"));
想点击按钮的同时删除图片,结果现在改变数据 图片文件变了 但是网页上的图片没变化
[解决办法]
代码看不出问题