Fill a DataSet with nearly 20,0000 records using SqlDataAdapter

Posted on


I want to fill a DataSet with 20,0000 records using a SqlDataAdapter by using this code:


If I fill a DataSet this way it takes a long time. Is there anything wrong with this?

This is my code:

connection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);

SqlCommand command = new SqlCommand("sp_DMS_Report_Generate", connection); 
command.CommandType = CommandType.StoredProcedure; 
command.Parameters.AddWithValue("@XML", reportCriteria.XML); 
command.CommandTimeout = 1000; 

SqlDataAdapter adapter = new SqlDataAdapter(command); 

return resultSet.Tables[0];


I would say the C# is fine, it’s your database that is the issue. Is the Stored procedure optimized? Are the tables in the proper normalization? Are your primary keys & foreign keys set up properly? (you should get the point by now)

Start there first since really everything is there.

Leave a Reply

Your email address will not be published. Required fields are marked *