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?
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).