首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

请大家Help!出现实时异常3001,参数类型不正确或在不可以接受的范围之内…(见代码)

2012-01-09 
请大家Help!!!出现实时错误3001,参数类型不正确或在不可以接受的范围之内……(见代码)想用Mschart做一个饼图

请大家Help!!!出现实时错误3001,参数类型不正确或在不可以接受的范围之内……(见代码)
想用Mschart做一个饼图:
  Option   Explicit  
Dim   rs1   As   ADODB.Recordset
Dim   rs2   As   ADODB.Recordset
Dim   rs3   As   ADODB.Recordset
Dim   rs4   As   ADODB.Recordset
Dim   rs5   As   ADODB.Recordset
Dim   SelectedSeries   As   Integer   '自定义变量
Dim   rs()   As   String   '提取记录集用的字符串数组
Dim   objRs   As   ADODB.Recordset
Private   Sub   Form_Load()
'On   Error   GoTo   DealError
        Dim   objCn   As   New   Connection
        '建立数据库连接
            objCn.ConnectionString   =   "Provider=Microsoft.Jet.OLEDB.4.0; "   &   _
                                        "Data   Source= "   &   App.Path   &   "\数据库\Score.mdb "
         
          objCn.Open
              Set   rs5   =   New   ADODB.Recordset
              Set   rs1   =   New   ADODB.Recordset
              Set   rs2   =   New   ADODB.Recordset
              Set   rs3   =   New   ADODB.Recordset
              Set   rs4   =   New   ADODB.Recordset
        '创建RecordSet对象,获取学生成绩信息
        Set   objRs   =   New   Recordset
        Set   objRs.ActiveConnection   =   objCn
          objRs.Open   "SELECT   *   FROM   学生成绩 "
      rs5.Open   "select   *   from   学生成绩   order   by   成绩 ",   objRs,   adOpenStatic,   adLockOptimistic
        Do   While   Not   rs5.EOF
        rs5.MoveNext
        Loop
      rs1.Open   "select   *   from   学生成绩   where   成绩   = "   +   Chr(39)   +   "优 "   +   Chr(39)   +   "order   by   成绩 ",   objRs,   adOpenStatic,   adLockOptimistic
        Do   While   Not   rs1.EOF
          rs1.MoveNext
            Loop


rs2.Open   "select   *   from   学生成绩   where   成绩   = "   +   Chr(39)   +   "良 "   +   Chr(39)   +   "order   by   成绩 ",   objRs,   adOpenStatic,   adLockOptimistic
Do   While   Not   rs2.EOF
rs2.MoveNext
Loop

rs3.Open   "select   *   from   学生成绩   where   成绩   = "   +   Chr(39)   +   "中 "   +   Chr(39)   +   "order   by   成绩 ",   objRs,   adOpenStatic,   adLockOptimistic
Do   While   Not   rs3.EOF
rs3.MoveNext
Loop

rs4.Open   "select*   from   学生成绩   where   成绩= "   +   Chr(39)   +   "差 "   +   Chr(39)   +   "order   by   成绩 ",   objRs,   adOpenStatic,   adLockOptimistic


Do   While   Not   rs4.EOF
rs4.MoveNext
Loop
objRs.ActiveConnection   =   Nothing         '取消数据库连接
        objCn.Close                                                   '关闭数据库连接
        Set   objCn   =   Nothing                                   '释放连接
        Exit   Sub
'DealError:
        'ShowError   =   "程序执行出错,错误信息如下: "   &   vbCrLf   &   Err.Description
       
        End   Sub

Private   Sub   McScore_SeriesSelected(Series   As   Integer,   MouseFlags   As   Integer,   Cancel   As   Integer)
Set   DataGrid1.DataSource   =   rs5
SelectedSeries   =   Series
End   Sub
Private   Sub   McScore_PointSelected(Series   As   Integer,   DataPoint   As   Integer,   MouseFlags   As   Integer,   Cancel   As   Integer)
SelectedSeries   =   Series
End   Sub
Private   Sub   McScore_Db1Click()
'改变ADO控件的记录源并刷新
Adoc1.RecordSource   =   rs(SeletedSeries)
Adoc1.Refresh
End   Sub

在rs5.Open   "select   *   from   学生成绩   order   by   成绩 ",   objRs,   adOpenStatic,   adLockOptimistic   总是出现如题错误,把objRs定义成Public也不能解决,初学很不明白怎么改。希望大家帮助。


[解决办法]
rs5.Open "select * from 学生成绩 order by 成绩 ", objRs, adOpenStatic, adLockOptimistic

objRs是你声明的记录集,应该是连接发对象

rs5.Open "select * from 学生成绩 order by 成绩 ", objCn, adOpenStatic, adLockOptimistic

热点排行