我在vb2005里面画曲线图。因为有限制条件,在dropdownlist里面换条件。点击BUTTON后第一次会出现曲线图,可是换了条件再点BUTTON时,曲线图没有变化,点刷新后会出现 重试 和 取消
这个问题怎么解决啊
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim mycnn As New SqlConnection
Dim objds1 As New DataSet
Dim MyCommand As New SqlDataAdapter
mycnn.ConnectionString = "Data Source=locahost;User ID=sa;Password=sa;Initial Catalog=current;integrated security=false"
mycnn.Open()
MyCommand = New SqlDataAdapter("select distinct DateTime,Value from table where code='" + jiancezhandian.Text + "'and DateTime>='" + starttime.Text + "'and DateTime<='" + totime.Text + "'and CommonName='" + jianceneirong.Text + "'", mycnn)
objds1 = New DataSet()
MyCommand.Fill(objds1, "table")
Dim MonNum() As String = New String(objds1.Tables(0).Rows.Count) {}
Dim MonCount() As String = New String(objds1.Tables(0).Rows.Count) {}
Dim i As Integer
For i = 0 To objds1.Tables(0).Rows.Count - 1
MonNum(i) = objds1.Tables(0).Rows(i)(0).ToString()
MonCount(i) = Round(objds1.Tables(0).Rows(i)(1).ToString(), 2)
Next
Dim strXdata As String = String.Empty
Dim strData As String
For Each strData In MonNum
strXdata += strData + ControlChars.Tab
Next
Dim strYdata As String = String.Empty '为y轴指定特定的字符串,以便与x轴相对应
Dim strValue As String
For Each strValue In MonCount
strYdata += strValue + ControlChars.Tab
Next
Dim objCSpace As Microsoft.Office.Interop.Owc11.ChartSpace = New Microsoft.Office.Interop.Owc11.ChartSpaceClass()
Dim objChart As Microsoft.Office.Interop.Owc11.ChChart = objCSpace.Charts.Add(0)
objChart.Type = Microsoft.Office.Interop.Owc11.ChartChartTypeEnum.chChartTypeLine
Dim strSeriesName As String = "图例 1"
objChart.HasLegend = True
objChart.HasTitle = True
objChart.Title.Caption = "分析图"
objChart.Axes(0).HasTitle = True
objChart.Axes(0).Title.Caption = "" '月份
objChart.Axes(1).HasTitle = True
objChart.Axes(1).Title.Caption = "数量"
objChart.SeriesCollection.Add(0)
objChart.SeriesCollection(0).SetData(ChartDimensionsEnum.chDimSeriesNames, ChartSpecialDataSourcesEnum.chDataLiteral, strSeriesName)
objChart.SeriesCollection(0).SetData(ChartDimensionsEnum.chDimCategories, ChartSpecialDataSourcesEnum.chDataLiteral, strXdata)
objChart.SeriesCollection(0).SetData(ChartDimensionsEnum.chDimValues, ChartSpecialDataSourcesEnum.chDataLiteral, strYdata)
Dim dl As Microsoft.Office.Interop.Owc11.ChDataLabels = objChart.SeriesCollection(0).DataLabelsCollection.Add()
Dim strAbsolutePath As String = (Server.MapPath(".")) + "\\test.gif"
objCSpace.ExportPicture(strAbsolutePath, "GIF", 600, 350)
Dim strRelativePath As String = "./test.gif"
Dim strImageTag As String = "<IMG SRC='" + strRelativePath + "'/>"
PlaceHolder1.Controls.Add(New LiteralControl(strImageTag))
' objCSpace.Refresh()
' mycnn.Close()
'Request.Url.ToString()
End Sub
点击BUTTON后第一次会出现曲线图,可是换了条件再点BUTTON时,曲线图没有变化,点刷新后会出现 重试和取消 ,不过点了重试 后曲线图才会变化。我想问一下,直接点击BUTTON,曲线图发生变化的代码。谢谢了。