C
C#Coder
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;
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;