I wrote this code:
SqlConnection Conn = new SqlConnection("ConnectionString");
SqlCommand cmd = new SqlCommand("select * from tablename", conn);
SqlDataReader dr = cmd.ExecuteReader();
datatable dt = new datatable();
dt.load(dr);
But I get an exception as shown below when I load data into the datatable because I have an xml column with a big size (102 MB).
Exception of type 'System.OutOfMemoryException' was thrown.
I'm very grateful if someone can give me the solution for this exception.
select *grabs all the data in the table, you can't handle huge datasets in such a simple way.readerto read one row at a time in a loop. Process each row as you go along. And dispose your connection and reader objects withusing