.exception类型'system.outOfMemory' [英] .exception of type 'system.outOfMemory'
问题描述
我正在运行一个程序,当我单击保存按钮时,异常为: - I am running a program in which when I click Save button it through exception as :- 这篇关于.exception类型'system.outOfMemory'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
'System.OutOfMemoryException'被抛出
代码崩溃的代码是: -
< pre lang =vb> Dim cmdDeleteData As New SqlCommand( 从temp_grimage_offline删除,
cmdDeleteData.ExecuteNonQuery()
Dim bulk_BeeEnn As 新 SqlBulkCopy(webCon)
bulk_BeeEnn.BulkCopyTimeout = 0
bulk_BeeEnn.DestinationTableName = temp_grimage_offline
bulk_BeeEnn.WriteToServer(ds.Tables( 0 ))
checkingForDataDuplicacy()
Dim cmd_insert As 新 SqlCommand( insert into emp.dbo.grimage(grno,grimage,stn,scansdate,tbb,topay,paid,[to],actualwt,chargedwt,nags,ftl,imageid,dgr,empid,grdate,nags_loose, +
运费,hamali,l_c,st_ser,附加费,vsc,stationary_ch,dd_chrgs,st_entry, total,upload_date)选择grno,grimage,stn, +
scanningdate,tbb, topay,付费,[to],actualwt,chargedwt,nags,ftl,imageid,dgr,empid, +
grdate,nags_loose,货运,哈mali,l_c,st_ser,surcharge,vsc,stationary_ch,dd_chrgs,st_entry,total,getdate() +
来自emp.dbo.temp_grimage_offline,webCon)
cmd_insert.CommandTimeout = 0
cmd_insert.ExecuteNonQuery()
Dim cmd_update As < span class =code-keyword>新 SqlCommand( update emp.dbo.grimage set flag = '1',其中flag ='0'或flag为null,localCon)
cmd_update.ExecuteNonQuery()
cmd_update.CommandTimeout = 0 如果没有看到崩溃的代码和发生问题的记录数量,那么几乎无法分辨你是什么人做错了。
但是,从你所解释的声音来看,如果你试图加载一张巨大的桌子,那么你真的会用RAM运行机器使用DataSet / DataTable对象一次性进入内存。
'System.OutOfMemoryException' was thrown
code where it crashes is :-
Dim cmdDeleteData As New SqlCommand("delete from temp_grimage_offline", webCon)
cmdDeleteData.ExecuteNonQuery()
Dim bulk_BeeEnn As New SqlBulkCopy(webCon)
bulk_BeeEnn.BulkCopyTimeout = 0
bulk_BeeEnn.DestinationTableName = "temp_grimage_offline"
bulk_BeeEnn.WriteToServer(ds.Tables(0))
checkingForDataDuplicacy()
Dim cmd_insert As New SqlCommand("insert into emp.dbo.grimage(grno,grimage,stn,scanneddate,tbb,topay,paid,[to],actualwt,chargedwt,nags,ftl,imageid,dgr,empid,grdate,nags_loose, " +
"freight,hamali,l_c,st_ser,surcharge,vsc,stationary_ch,dd_chrgs,st_entry,total,upload_date) select grno,grimage,stn, " +
"scanneddate,tbb,topay,paid,[to],actualwt,chargedwt,nags,ftl,imageid,dgr,empid, " +
"grdate,nags_loose,freight,hamali,l_c,st_ser,surcharge,vsc,stationary_ch,dd_chrgs,st_entry,total,getdate() " +
"from emp.dbo.temp_grimage_offline", webCon)
cmd_insert.CommandTimeout = 0
cmd_insert.ExecuteNonQuery()
Dim cmd_update As New SqlCommand("update emp.dbo.grimage set flag = '1' where flag = '0' or flag is null", localCon)
cmd_update.ExecuteNonQuery()
cmd_update.CommandTimeout = 0
Without seeing your code where it crashes and the number of records where the problem occurs, it's pretty much impossible to tell you what you're doing wrong.
But, from the sounds of what you have explained, you are literally running the machine out of RAM if you're trying to load a huge table into memory all at once with a DataSet/DataTable object.