从sql数据库中选择数据时出现OutOfMemoryException [英] OutOfMemoryException when selecting data from sql database

查看:524
本文介绍了从sql数据库中选择数据时出现OutOfMemoryException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个表包含近90个缺失到1 cr的记录.我想将此数据保存到文本文件.我试图将记录选择到数据表中,发生"OutofMemoryExceptionerror"

代码:

A table contains almost 90 lacks to 1 cr records. I want to save this data to text file. I am trying to select records into datatable, ''OutofMemoryExceptionerror'' occurred

code:

Imports System.Data.Sql
Imports System.Data.SqlClient


Dim con As New SqlConnection(Connection)
Dim CategoryAdapter As New SqlDataAdapter("select sserial, spin from tbl_serial_table", con)
Dim SerialData As New DataSet()
CategoryAdapter.Fill(SerialData, "Data")



当我尝试填充数据集时发生错误.
请指导...



When I try to fill dataset error occurred.
Please guide...

推荐答案

如果您尝试使用超出系统负担能力的内存,可以得到什么指南?无论您的系统是什么,最终您都可以始终面对内存不足的情况.这是自然的,通常是不可避免的.

因此,没有什么特别的建议.好吧,获得具有更多内存的客户端系统,最有可能基于64位指令集体系结构之一,更喜欢选择查询,并正确处理内存不足异常.

关于查询,请看一下您的示例:您正在尝试一次检索整个表.这样的查询是非常不寻常的,没有任何意义.使用WHERE子句等,请记住,使用参数化查询非常重要.

—SA
What guide can you get if you are trying to use more memory than a system can afford? No matter what is your system, eventually you can always face the situation when your memory is not enough. This is natural and generally unavoidable.

So, there is nothing special to advise. Well, get a client system with more memory, most likely based on one of 64-bit instruction-set architectures, prefer more selective queries, handle out-of-memory exceptions properly.

As to the queries, look at your sample: you are trying to retrieve the whole table at once. Such queries are very unusual and make little sense. Use WHERE clause, etc., remember that using parametrized queries is important.

—SA


这篇关于从sql数据库中选择数据时出现OutOfMemoryException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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