Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#2.0 C# C#4.0 ASP:NET
I want to add a Table dynamically when the page is load with database table. But it's not working. Its give me a Exception:
An exception of type 'System.OutOfMemoryException' occurred in System.Web.dll but was not handled in user code
 
My Code:
if (!IsPostBack == true)
            {
                System.Web.UI.WebControls.Login LoginControl = (System.Web.UI.WebControls.Login)PreviousPage.FindControl("Login1");
                if (LoginControl != null)
                {
                    TextBox UserName = (TextBox)LoginControl.FindControl("UserName");
                    if (UserName != null)
                    {
                        superEmail = UserName.Text.ToString();
                        //db.command.Parameters.Add("@SupervisorEmail", SqlDbType.VarChar).Value = superEmail.ToString();
                        //grdView.DataSource = db.Adapter("spVerify", true);
                        //grdView.DataBind();
                        lbl1.Text = superEmail.ToString();
                        db.command.Parameters.Add("@SupervisorEmail", SqlDbType.VarChar).Value = superEmail.ToString();
                        db.Adapter("spVerify", "okay", true);
                        for (int i = 0; i < db.dataSet.Tables["okay"].Rows.Count; i++)
                        {
                            TableRow tr = new TableRow();
                            for (int j = 0; j < 5; i++)
                            {
                                TableCell tc = new TableCell();
                                if(j == 0)
                                {
                                    tc.Text = db.dataSet.Tables["okay"].Rows[0][j].ToString();
                                    tr.Cells.Add(tc);
                                }
                                if (j == 1)
                                {
                                    tc.Text = db.dataSet.Tables["okay"].Rows[0][j].ToString();
                                    tr.Cells.Add(tc);
                                }
                                if (j == 2)
                                {
                                    tc.Text = db.dataSet.Tables["okay"].Rows[0][j].ToString();
                                    tr.Cells.Add(tc);
                                }
                                if (j == 3)
                                {
                                    LinkButton link = new LinkButton();
                                    link.ID = "l" + i.ToString();
                                    link.Text = db.dataSet.Tables["okay"].Rows[0][4].ToString();
                                    link.EnableViewState = true;
                                    link.CommandName = db.dataSet.Tables["okay"].Rows[0][j].ToString();
                                    link.Command += new CommandEventHandler(link_Command);
                                    //tc.Text = db.dataSet.Tables["okay"].Rows[0][j].ToString();
                                    tc.Controls.Add(link);
                                    tr.Cells.Add(tc);
                                }
                                if (j == 4)
                                {
                                    tc.Text = db.dataSet.Tables["okay"].Rows[0][j].ToString();
                                    tr.Cells.Add(tc);
                                }
                            }
                            tbl.Rows.Add(tr);
                        }
                    }
                }
                else
                {
                    //Label1.Text = "Cannot find user name in Login control.";
                }
            }
 
Please help me.
Posted 10-Feb-13 23:21pm
Comments
ProgramFOX at 11-Feb-13 4:24am
   
What's the row count?
digimanus at 11-Feb-13 4:56am
   
exactly. more than 200,000 rows can be problematic
Michael J. Eber at 11-Feb-13 14:57pm
   
Try to step through your code and follow the process. Frequently when I get an out of memory exception it is because I've inadvertantly triggered an event that loops back into my original code. As a result I have a sequence of ....

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

There is not enough RAM on the server to handle your operation. Make the operation less memory consuming or add more memory to the server will solve the problem.
  Permalink  
Comments
UL UL ALBAB at 11-Feb-13 4:51am
   
I am using 6 GB RAM with my Core"i5 Laptop. I think this not problem.
Marco Bertschi at 11-Feb-13 4:55am
   
Every application has (in Windows) a pool of memory assigned which is smaller than the total amount of memory available because there are always other memory-consuming applications running. This pool is usually only a few megabytes big within a DotNet app.... So the best way for you would be to make the operation less memory-consuming.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 6,569
1 Sergey Alexandrovich Kryukov 6,168
2 DamithSL 5,228
3 Manas Bhardwaj 4,717
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web02 | 2.8.1411022.1 | Last Updated 11 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100