为System.OutOfMemoryException当填充DataAdapter的? [英] system.outofmemoryexception When filling DataAdapter?

查看:649
本文介绍了为System.OutOfMemoryException当填充DataAdapter的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不得不从DB拉 150K 记录。我使用 da.Fill(DS,查询)及其投掷的System.OutOfMemoryException

I have to pull 150K records from DB. I am using da.Fill(ds,"Query") and its throwing system.outofmemoryexception.

Dim daGrid As New SqlDataAdapter(sqlcmd_q)
daGrid.Fill(dsGrid, "Query")
daGrid.Dispose()

我只需要这个数据表。我不能使用XML。因为我需要分配这MSChartControl显示Scot​​terPlot。

I need this datatable only. I cannot use XML. because I need assign this to MSChartControl to display ScotterPlot.

有什么建议?

推荐答案

这是我检查的第一件事是要多少列返回,以及他们的数据类型。虽然150K记录是很多的,它不应该给你一个OOM异常,除非每个记录的长度约为13K(在32位机器上)。这表明,我认为你要么回的方式更多的领域比你需要的,或者有些区域是非常大的字符串或二进制数据。尝试削减SELECT语句只返回绝对所需显示的字段。

The first thing that I'd check is how many columns you are returning, and what their data types are. Although 150K records is a lot, it shouldn't give you an OOM exception unless each record is about 13K in length (on a 32-bit machine). This suggests to me that you are either returning way more fields than you need, or perhaps that some of the fields are very large strings or binary data. Try cutting down the select statement to only return the fields that are absolutely needed for the display.

如果不工作,你可能需要从一个DataTable移动到自定义数据类型(与相应的字段的类)的列表。

If that doesn't work, you may need to move from a DataTable to a list of a custom data type (a class with the appropriate fields).

这篇关于为System.OutOfMemoryException当填充DataAdapter的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆