以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  System.OutOfMemoryException的异常  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=139067)

--  作者:xluoping
--  发布时间:2019/8/5 10:01:00
--  System.OutOfMemoryException的异常
批量增加行,发生System.OutOfMemoryException异常,用的.accdb数据库,问题出在哪里?

Dim ii As Integer
For Each dr As DataRow In DataTables("客户list").Select("代码 is not null and 完成 = false")
    Dim st As String = dr("代码")
    Dim sti As Integer = st.LastIndexOf("<tbody>") + 7
    Dim stl As Integer = st.LastIndexOf("</tbody>")
    st = st.SubString(sti,stl-sti).Replace("</tr>","|")
    Dim  Multi As String = st
    Dim Values() As String
    Values = Multi.split("|")
    For Index As  Integer = 0 To Values.Length - 1
        If Values(Index).Contains("<td") Then
            Dim drr As DataRow = DataTables("客户").AddNew()
            drr("代码") = Values(Index)
            drr("客户list") = dr("_Identify")
        End If
    Next
    dr("完成") = True
    ii = ii + 1
    If ii Mod 10 = 0 Then
        DataTables("客户").Save()
        DataTables("客户list").Save()
    End If
Next
MessageBox.Show("ok")


--  作者:有点蓝
--  发布时间:2019/8/5 10:22:00
--  
添加了太多的行吧。建议使用SQLcommand插入后台数据库,或者返回临时表进行新增