 |
|
| .NET DotNet Forum Index » ADO .NET Forum » System.OutOfMemoryException in DataAdapter... |
|
Page 1 of 1 |
|
| Author |
Message |
| C#Coder... |
Posted: Mon Oct 05, 2009 7:33 pm |
|
|
|
Guest
|
I am using a DataAdapter to collect the results of a stroed proc into a
DataSet. However when I run this application I get the following exception...
I know the data coming out of running the Stored Proc is hugh. Is there an
efficient way to get the data instead which is also permformant enough..
Exception of type 'System.OutOfMemoryException' was thrown.
at System.Data.Common.StringStorage.SetCapacity(Int32 capacity)
at System.Data.RecordManager.set_RecordCapacity(Int32 value)
at System.Data.RecordManager.GrowRecordCapacity()
at System.Data.RecordManager.NewRecordBase()
at System.Data.DataTable.NewRecordFromArray(Object[] value)
at System.Data.DataTable.LoadDataRow(Object[] values, Boolean
fAcceptChanges)
at System.Data.ProviderBase.SchemaMapping.LoadDataRow()
at System.Data.Common.DataAdapter.FillLoadDataRow(SchemaMapping mapping)
at System.Data.Common.DataAdapter.FillFromReader(DataSet dataset,
DataTable datatable, String srcTable, DataReaderContainer dataReader, Int32
startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object
parentChapterValue)
at System.Data.Common.DataAdapter.Fill(DataSet dataSet, String srcTable,
IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable,
IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
<<<<<<<<<<<<<<<<<<<<<<<<<<<
DataSet ds = new DataSet();
using (SqlConnection cn = new SqlConnection(cnnMasterString))
{
SqlCommand cmd = new SqlCommand();
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.Connection = cn;
cmd.CommandText = strStoredProcName;
cmd.CommandTimeout = commandTimeOut;
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = cmd;
try
{
// Fill the DataSet.
adapter.Fill(ds);
}
catch
{
throw;
}
finally
{
cmd.Dispose();
}
}
return ds; |
|
|
| Back to top |
|
|
|
| Miha Markic... |
Posted: Tue Oct 06, 2009 12:20 am |
|
|
|
Guest
|
Why don't you limit the amount of the data in stored proc? Why would you
need that much data?
Anyway, you might try using a datareader instead of filling a dataset.
--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: blog.rthand.com |
|
|
| Back to top |
|
|
|
| Patrice... |
Posted: Tue Oct 06, 2009 7:49 am |
|
|
|
Guest
|
How much data re you trying to retrieve ? Do you need them all ?
Usually the idea is :
- if this to present each of those rows to the user, this is likely useless
as the user will filter them out to find out what he is interested in. so it
could be better to filter before getting the data rather than after.
- if this is to perform a somewhat compelx process it could be better to do
this using a stored procedure so that the all calculation takes place on the
server. This way you don"t have to retrieve all those details, you can just
get the needed results...
--
Patrice |
|
|
| Back to top |
|
|
|
| Paul... |
Posted: Thu Oct 08, 2009 3:12 am |
|
|
|
Guest
|
Simple.....
Don't use datasets.
Use DataReaders and model objects.
More performant and if you keep your model objects data specific (DTO/BLL
elsewhere) they will have a much smaller footprint than datasets by a fair
way.
On a serious note tho, this will only get worse as more data is added so you
really need to look at workflow solutions and why you need all the data at
once.
"C#Coder" <CCoder at (no spam) discussions.microsoft.com> wrote in message
news:FFCFA19B-6E28-4871-8339-A593EABF4C25 at (no spam) microsoft.com...
Quote: I am using a DataAdapter to collect the results of a stroed proc into a
DataSet. However when I run this application I get the following
exception...
I know the data coming out of running the Stored Proc is hugh. Is there an
efficient way to get the data instead which is also permformant enough..
Exception of type 'System.OutOfMemoryException' was thrown.
at System.Data.Common.StringStorage.SetCapacity(Int32 capacity)
at System.Data.RecordManager.set_RecordCapacity(Int32 value)
at System.Data.RecordManager.GrowRecordCapacity()
at System.Data.RecordManager.NewRecordBase()
at System.Data.DataTable.NewRecordFromArray(Object[] value)
at System.Data.DataTable.LoadDataRow(Object[] values, Boolean
fAcceptChanges)
at System.Data.ProviderBase.SchemaMapping.LoadDataRow()
at System.Data.Common.DataAdapter.FillLoadDataRow(SchemaMapping mapping)
at System.Data.Common.DataAdapter.FillFromReader(DataSet dataset,
DataTable datatable, String srcTable, DataReaderContainer dataReader,
Int32
startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object
parentChapterValue)
at System.Data.Common.DataAdapter.Fill(DataSet dataSet, String srcTable,
IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable,
IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
Code Snippet:
DataSet ds = new DataSet();
using (SqlConnection cn = new SqlConnection(cnnMasterString))
{
SqlCommand cmd = new SqlCommand();
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.Connection = cn;
cmd.CommandText = strStoredProcName;
cmd.CommandTimeout = commandTimeOut;
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = cmd;
try
{
// Fill the DataSet.
adapter.Fill(ds);
}
catch
{
throw;
}
finally
{
cmd.Dispose();
}
}
return ds; |
|
|
| Back to top |
|
|
|
| misfit815... |
Posted: Wed Oct 28, 2009 10:01 am |
|
|
|
Guest
|
Does anyone have metrics on this? What *are* the limits? Is it running up
against a fixed constraint, or does it really exhaust system resources?
In our case, we have a large, random data set which is using SqlBulkCopy to
get into the database. Except for this particular constraint, DataSets really
are our most viable option. |
|
|
| Back to top |
|
|
|
|
|
All times are GMT - 5 Hours
The time now is Sun Nov 29, 2009 2:46 pm
|
|