用vb6.0的mschart控件与数据库连接画曲线图

OnErrorResumeNextDimiAsIntegerDimconnAsNewADODB.ConnectionDimrsAsNewADODB.RecordsetSe... On Error Resume Next
Dim i As Integer
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Set conn = New ADODB.Connection
Set rs = New ADODB.Recordset

conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "C:\Documents and Settings\Administrator\桌面\vb程序\tgthtn.mdb"
conn.Open
rs.Open "select * from tgthtn", conn, adOpenKeyset, adLockOptimistic

' Set MSChart1.DataSource = rs

With MSChart1
.chartType = 3
.Plot.Axis(VtChAxisIdY).ValueScale.Auto = False

.Plot.Axis(VtChAxisIdY).ValueScale.Maximum = 100
.Plot.Axis(VtChAxisIdY).ValueScale.Minimum = 0
.Plot.Axis(VtChAxisIdY).ValueScale.MinorDivision = 1

.ColumnCount = 3

.Plot.Axis(VtChAxisIdX).ValueScale.Auto = True
.Plot.Axis(VtChAxisIdX).ValueScale.MinorDivision = 1

.Plot.Axis(VtChAxisIdX, 0).AxisTitle = "时间"
.Plot.Axis(VtChAxisIdY, 0).AxisTitle = "温度"

.Plot.Axis(VtChAxisIdX, 0).AxisTitle.VtFont.Size = 15
.Plot.Axis(VtChAxisIdY, 0).AxisTitle.VtFont.Size = 15

.Title.Text = "供暖运行曲线图"
.Title.Font.Size = 25
.ShowLegend = True

For i = 1 To .Plot.SeriesCollection.Count
.Plot.SeriesCollection(i).DataPoints(-1).DataPointLabel.LocationType = VtChLabelLocationTypeAbovePoint
Next

If rs.RecordCount > 0 Then
rs.MoveFirst
Else
Exit Sub
End If

For i = 0 To rs.RecordCount - 1

.Column = 1 '室温曲线所在列
.RowCount = rs.RecordCount
.Row = i + 1
.RowLabel = CStr(rs("时间"))
.Data = rs("tn")
.ColumnLabel = "室温"

'//供水温度显示
.Column = 2 '供水温度曲线所在列
.Data = rs("tg")
.ColumnLabel = "供水温度"

'//回水温度显示
.Column = 3 '回水温度曲线所在列
.Data = rs("th")
.ColumnLabel = "回水温度"

rs.MoveNext
Next

End With

End Sub

Private Sub Command2_Click() '下列示例设置图表查看距离和轴分段间距。

' Change the chart type to 3D Bar.
MSChart1.chartType = VtChChartType3dBar
With MSChart1.Plot
' Changes 3d bar chart's viewing.
.DepthToHeightRatio = 2
.WidthToHeightRatio = 2
' Changes the spacing between divisions on the
' X-Axis.
.xGap = 0
' Changes the spacing between divisions on the
' Z-Axis.
.zGap = 0.8
End With

End Sub
从网上找了个程序自己改了改,数据库如图,运行时横坐标显示R1、R2、R3、R4、R5,曲线的数值也不对,应该是没有和数据库连接成功,哪位高手帮我看看哪里出错了,万分感谢!
建立了form窗体后,添加了mschart控件和两个command控件,需要怎样设置他们的属性呢?
展开
 我来答
factor_hg
2011-07-08 · TA获得超过1425个赞
知道小有建树答主
回答量:1444
采纳率:0%
帮助的人:412万
展开全部
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "C:\Documents and Settings\Administrator\桌面\vb程序\tgthtn.mdb"
改为
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="C:\Documents and Settings\Administrator\桌面\vb程序\tgthtn.mdb"
更多追问追答
追问
不行啊,修改后运行时提示“缺少语句结束”。
追答
引号错误 多了个引号
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Administrator\桌面\vb程序\tgthtn.mdb;Persist Security Info=False"
或者这样改
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & app.path & "\tgthtn.mdb;Persist Security Info=False"
laowanghao330
2011-07-09 · TA获得超过158个赞
知道答主
回答量:202
采纳率:0%
帮助的人:190万
展开全部
用Line控件,创建控件数组,然后根据数据设置点1和点2的位置
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式