以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 引发类型为“System.OutOfMemoryException”的异常。 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=140690) |
-- 作者:xluoping -- 发布时间:2019/9/11 15:16:00 -- 引发类型为“System.OutOfMemoryException”的异常。 运行几十行后错误,再运行几十行又错误,什么原因?一共4000行 Dim dt As DataTable = DataTables("MSDS网址") Dim iii As Integer For Each dr As DataRow In dt.Select("_Identify is not null","化学品名称") dr("第六列") = iii If dr.IsNull("代码") = False AndAlso dr.IsNull("代码2") Then Dim Multi As String = dr("代码") If Multi <> "" Then Dim Values() As String Values = Multi.split("|") Dim dms As String For Index As Integer = 0 To Values.Length - 1 If dms <> "" Then dms = dms & "|" & Values(Index) & "^" & Index Else dms = dms & Values(Index) & "^" & Index End If Next dr("代码2") = dms dr("代码3") = Values.Length - 1 End If End If iii = iii + 1 Next dt.Save() MessageBox.Show("ok")
|
-- 作者:有点蓝 -- 发布时间:2019/9/11 15:27:00 -- 应该不只是这种代码的原因。到命令窗口单独运行这段代码有没有问题? systemready = false 1楼的代码 systemready = true
[此贴子已经被作者于2019/9/11 15:28:09编辑过]
|
-- 作者:xluoping -- 发布时间:2019/9/11 16:06:00 -- 还是错误 |
-- 作者:有点蓝 -- 发布时间:2019/9/11 16:20:00 -- 实例发上来测试一下 |
-- 作者:xluoping -- 发布时间:2019/9/11 16:30:00 -- 改成这样就没有问题。是不是字符合并的问题,太长了 Dim dt As DataTable = DataTables("MSDS网址") Dim iii As Integer For Each dr As DataRow In dt.Select("_Identify is not null","化学品名称") dr("第六列") = iii If dr.IsNull("代码") = False AndAlso dr.IsNull("代码2") Then Dim Multi As String = dr("代码") If Multi <> "" Then Dim Values() As String Values = Multi.split("|") Dim s As new StringBuilder For Index As Integer = 0 To Values.Length - 1 If Index > 0 Then s.AppendLine("|" & Values(Index) & "^" & Index) Else s.AppendLine(Values(Index) & "^" & Index) End If Next Dim dms As String = s.Tostring dms = dms.Replace(vbcrlf,"") dr("代码2") = dms dr("代码3") = Values.Length - 1 End If End If iii = iii + 1 \'Exit For Next dt.Save() MessageBox.Show("ok")
|
-- 作者:有点蓝 -- 发布时间:2019/9/11 16:52:00 -- 应该是的 |