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()
I need this datatable only. I cannot use XML. because I need assign this to MSChartControl to display ScotterPlot.
Any suggestions?
OutOfMemoryException Exception of type 'System. OutOfMemoryException' was thrown. To resolve this issue, I had to restart Visual Studio or go to the Windows Task Manager and terminate IIS Express process. This error could happen due to a variety of reasons related to memory consumption of the application.
When data structures or data sets that reside in memory become so large that the common language runtime is unable to allocate enough contiguous memory for them, an OutOfMemoryException exception results.
The Fill method of the DataAdapter is used to populate a DataSet with the results of the SelectCommand of the DataAdapter . Fill takes as its arguments a DataSet to be populated, and a DataTable object, or the name of the DataTable to be filled with the rows returned from the SelectCommand .
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.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With