如何用vb中的mschart显示柱状图,数据来源于oracle,并且显示的是完成量与未完成量的百分比,大家帮帮忙

2024-12-25 12:27:51
推荐回答(1个)
回答1:

'Ctrl+t找Microsoft DataGrid Control....
'菜单"工程"->"引用" 找 Microsoft ActiveX Data Object....

Dim cn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim SqlStr As String
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=MyOracleDB;User Id=myUsername;Password=myPassword;Integrated Security=no;"
SqlStr = "Select * From 某个表"
rst.CursorLocation = adUseClient
rst.Open SqlStr, cn, adOpenDynamic, adLockOptimistic, adCmdText '打开记录集
Set MsChart1.DataSource = rst '给MsChart1修改数据源