C# system.outofmemoryexception
<p>I have to deal with a table that has two columns and 80000 rows.I need to have a comparison on that table between the two columns which is resulting in a system.out of memory exception when I run it.</p>

<p>I will compare the first record value with rest of the 79,999 <strong>records</strong> i.e.(1,1),(1,2),
.....(1,79999), (2,1),(2,2),....(2,79999)......(3,1),(3,2),....(3,79999)...</p>

<p>how to handle this situation</p>

<p>thanks in advance</p>

<p>Here is my code:</p>

<pre><code> SqlCommand cmd = new SqlCommand("select (g.gene),n.goterm,(n.gene) from genematrix g  join genematrix n on n.goterm=g.goterm where g.id&lt;n.id", con);
    SqlDataAdapter da = new SqlDataAdapter(cmd);
    DataSet ds = new DataSet();
    da.Fill(ds);
</code></pre>

<p>Table name GeneMatrix:</p>

<pre><code>GoTerm    Gene

1a       gene1
2b       gene1
1a       gene2
2b       gene3
</code></pre>

<p>so on till 80000 records...........</p>

<p>The above one is the table structure from which i will be comparing first Gene record with all other gene records and then go for the second gene record and start comparing it to all other records...so on till the last gene.</p>

<p>when i compare gene1 with gene2 for common go terms the result is like </p>

<pre><code>gene1 gene2 1a
gene1 gene3 2b
</code></pre>

<p>My above query returns the output correctly ,but the problem is ..a system.outofmemoryexception is shown and i couldn't get the query run completely till the end.</p>
