求助:用VB+ADO+Access,在用SQL语句查询大量大数据字段时出现“内存溢出”错误,在vb下无错误,编译成EXE后出现。请教各位大虾,是什么问题,怎么解决?

解决方案 »

  1.   

    可能是你定義的變量類型有誤,例如Inter的值的大小是:-36565到35689之間,具體去找書,如果數值大用double
      

  2.   

    很有可有是你定义的变量超过了他的最大值,便会产生溢出错误~!
    在程序前面加一句 on error resume next 试试看还有没有溢出错误了
    或是按F8,跟踪执行一下,看看是哪行语句错了
      

  3.   

    Set cn = New ADODB.Connection
    Set rs = New ADODB.Recordset
    cn.CursorLocation = adUseClient
    cn.ConnectionString = "DBQ=" & App.Path & "\data\db1.mdb;DefaultDir=" & _
            App.Path & "\data;Driver={Microsoft Access Driver (*.mdb)};" & _
            "DriverId=25;FIL=MS Access;ImplicitCommitSync=Yes;" & _
            "MaxBufferSize=4096;MaxScanRows=18;PageTimeout=15;SafeTransactions=0;" & _
            "Threads=3;UID=ADMIN;UserCommitSync=Yes;PWD=admind1234;"  '此处是设置密码的地方
    cn.open
    'cn.open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\data\db1.mdb;"
                      'cn.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=app.path +'\data\db1.mdb';"           'Initial Catalog=pubs;User Id=<Your Userid>;Password=<Your Password>"'''''''''''''
    If Check4.Value = Checked Then
    rs.open "select * from 财会目录 where 名称 = '" & searchDirPlace & "' and leaf_ID=0", cn, adOpenDynamic, adLockOptimistic
    If Not rs.EOF Thenaaa = rs.Fields("ID")
    rs.Close
    Else
    rs.Close
    MsgBox "没有符合条件的文章!", vbOKOnly + vbInformation, "抱歉!"
    Exit Sub
    End IfEnd If
    '''''''''''strFilter = Trim(IIf(strsearch = "", "'=ALL'", "内容备注 like " & "'%" & strsearch & "%'")) & " and " & Trim(IIf(searchName = "", "'=ALL'", "名称 like " & "'%" & searchName & "%'")) & " and " & Trim(IIf(searchFileClass = "", "'=ALL'", "file_type like " & "'%" & searchFileClass & "%'")) & " and " & Trim(IIf(searchManger = "", "'=ALL'", "发文机关 like " & "'%" & searchManger & "%'")) & " and " & Trim(IIf(searchfileNo = "", "'=ALL'", "文件号 like " & "'%" & searchfileNo & "%'")) & " and " & Trim("file_date between #" & DTPicker1.Value & "# and #" & DTPicker2.Value & "#") & " and " & Trim(IIf(searchDirPlace = "", "'=ALL'", "枝叶 = " & "" & aaa & ""))
    'Trim(IIf(Text1.Text = "", "'=ALL'", "姓名 like " & "'%" & Text1.Text & "%'"))
    'strFilter = " " & stroption & " like " & " '% " & strsearch & " %' "
    strgoods = "*" '"内容"
    'c.CommandText = "select * from 其他 where " & Trim(IIf(Text1.Text = "", "'=ALL'", "姓名 like " & "'%" & Text1.Text & "%'")) & "and " & Trim(IIf(combo1.Text = "", "'=ALL'", "学号='" & Trim(combo1.List(combo1.ListIndex)) & "'")) & "and " & Trim(IIf(text4.Text = "", "'=ALL'", "性别='" & Trim(text4.List(text4.ListIndex)) & "'")) & " and " & Trim(IIf(Combo3.Text = "", "'=ALL'", "计算机水平='" & Trim(Combo3.List(Combo3.ListIndex)) & "'")) & " and " & Trim(IIf(Combo4.Text = "", "'=ALL'", "英语水平='" & Trim(Combo4.List(Combo4.ListIndex)) & "'")) & " and " & Trim(IIf(Combo5.Text = "", "'=ALL'", "就业意愿='" & Trim(Combo5.List(Combo5.ListIndex)) & "'")) & " and " & Trim(IIf(Combo6.Text = "", "'=ALL'", "就业方向='" & Trim(Combo6.List(Combo6.ListIndex)) & "'")) & " and " & Trim(IIf(Combo7.Text = "", "'=ALL'", "是否签约='" & Trim(Combo7.List(Combo7.ListIndex)) & "'")) & " and " & Trim(IIf(Combo8.Text = "", "'=ALL'", "学生干部='" & Trim(Combo8.List(Combo8.ListIndex)) & "'")) & "" 'and 前后必须要有空格,否则就出错
    If strsearch = "" And Check1.Value = Unchecked And Check2.Value = Unchecked And Check3.Value = Unchecked And Check4.Value = Unchecked And Check5.Value = Unchecked And Check6.Value = Unchecked Then
        MsgBox "请输入查询内容!", vbOKOnly, "缺少搜索内容"
        Exit Sub
    End If
    strSQL = "Select " & strgoods & " From " & strtable & " Where " & strFilter & ";"
    'strSQL = "Select * From 财会目录 Where 内容备注 like '%" & strsearch & "%' and 名称 like '%" & searchName & "%';"rs.open strSQL, cn, adOpenDynamic, adLockOptimistic
    'rs.Open "select * from 财会目录 where file_date between '" & Format(DTPicker1.Value, "yyyy-mm-dd") & "' and '" & Format(DTPicker2.Value, "yyyy-mm-dd") & "'", cn, 3, 1
    'rs.Open "select * from 财会目录 where file_date between '" & Format(DTPicker1.Value) & "' and '" & Format(DTPicker2.Value) & "'", cn, adOpenKeyset, adLockOptimistic