Click here to Skip to main content
16,012,045 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
hello sir stackoverflow expection error genrated in my program . and just i debug project window ask me

error msg is:
open a small window

WebDev.WebServer40.exe has stopped working
A problem caused the program to stop working correctly. please close the program
Close the program
Debug the Program



sql srver table
--------------------------------------------------
create table tblRegistraition
(
id int identity (1,1) primary key not null,
Name varchar(100),
Email varchar(60),
password varchar(60),
Mobile varchar(15),
City varchar(100),
Createdate datetime default getdate(),
Active bit default (1)
)
---------------------------------------

my gridTest.aspx code:
============================================================================
<body>
    <form id="form1" runat="server">
    <div>

    <asp:LinkButton ID="lnkEmp" runat="server" Text="Show Employee Information"
            onclick="lnkEmp_Click"></asp:LinkButton>
    <br /><br />
    <asp:GridView ID="GridEmp" runat="server" AutoGenerateColumns="false"
            AutoGenerateEditButton="true" AutoGenerateDeleteButton="true"
            OnRowCancelingEdit="GridEmp_RowCancellingEdit"
            OnRowDeleting="GridEmp_RowDeleting" OnRowEditing="GridEmp_RowEditing"
            OnRowUpdating="GridEmp_RowUpdating"
           >
    <Columns>
    <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="" />
    <asp:BoundField DataField="password" HeaderText="Password" SortExpression="" />
    <asp:BoundField DataField="Mobile" HeaderText="Mobile" SortExpression="" />
    <asp:TemplateField>
    <ItemTemplate>
    <asp:HiddenField ID="hdnEmpid" runat="server" Value='<%# Eval("id") %>' />
    </ItemTemplate>
    </asp:TemplateField>
    </Columns>
    </asp:GridView>
    </div>
    </form>
</body>
</div>
</form>


gridTest.aspx.cs  code is:
===============================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;


public partial class grid : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    Blayer obj = new Blayer();
  //  DataTable dt = new DataTable();

    protected void GridEmp_RowCancellingEdit(object sender, GridViewCancelEditEventArgs e)
    {
        GridEmp.EditIndex = -1;
        lnkEmp_Click(sender, e);

    }
    protected void GridEmp_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        HiddenField hdnid = (HiddenField)GridEmp.Rows[e.RowIndex].FindControl("hdnid");
        int eid = Convert.ToInt32(hdnid.Value);
        obj.Delete(eid);
        lnkEmp_Click(sender, e);

    }
    protected void GridEmp_RowEditing(object sender, GridViewEditEventArgs e)
    {
        GridEmp.EditIndex = e.NewEditIndex;
        lnkEmp_Click(sender, e);
    }
    protected void GridEmp_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        TextBox txtName = (TextBox)GridEmp.Rows[e.RowIndex].Cells[1].Controls[0];
        string Name = txtName.Text;
        TextBox txtpwd = (TextBox)GridEmp.Rows[e.RowIndex].Cells[2].Controls[0];
        string password = txtpwd.Text;
        TextBox txtMobile = (TextBox)GridEmp.Rows[e.RowIndex].Cells[3].Controls[0];
        string Mobile = txtMobile.Text;

        HiddenField hdnid = (HiddenField)GridEmp.Rows[e.RowIndex].FindControl("hdnid");
        int id = Convert.ToInt32(hdnid.Value);

        obj.Update(id, Name, password, Mobile);
        GridEmp.EditIndex = -1;
        lnkEmp_Click(sender, e);
    }
    protected void lnkEmp_Click(object sender, EventArgs e)
    {
        GridEmp.DataSource = obj.BlShowEmp();
        GridEmp.DataBind();
    }
}


BLayer code is:
============================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
using System.Web.Configuration;


/// <summary>
/// Summary description for Blayer
/// </summary>
public class Blayer
{
    public Blayer()
    {
    }

    SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["Strcon"].ConnectionString);
    Blayer obj = new Blayer();

    public DataTable BlShowEmp()
    {
        con.Open();
        SqlCommand cmd = new SqlCommand("select Name,password,Mobile from tblRegistraition where Active=1", con);
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataTable dt = new DataTable();
        da.Fill(dt);
        con.Close();
        return dt;

    }


    public void Delete(int eid)
    {
        SqlCommand cmd = new SqlCommand("update tblRegistraition set Active=0 where id="+eid, con);
        con.Open();
        cmd.ExecuteNonQuery();
        con.Close();

    }

    public void Update(int id,string Name, string pwd, string Mobile)
    {
        string query = string.Format("update tblRegistraition Name='{0}',passwored='{1}',Mobile='{2}' where id='{3}", Name, pwd, Mobile);
        SqlCommand cmd = new SqlCommand(query, con);
        con.Open();
        cmd.ExecuteNonQuery();
        con.Close();

    }


}
Posted
Comments
Sergey Alexandrovich Kryukov 17-Aug-13 2:51am    
Did you try to debug it using the debugger?
—SA

1 solution

You cannot ask such question every time such situation appears. It will really be the best for you if you learn how to deal with such problem by yourself. This thing is usually pretty easy to locate and debug, but will need some converging steps.

Almost 100% of certainty that this is result of "infinite" recursion or mutual recursion:
http://en.wikipedia.org/wiki/Recursion[^],
http://en.wikipedia.org/wiki/Mutual_recursion[^].

Such problems can be resolved in a very systematic way using the debugger. First, you observe where the exception is thrown. Put a break point before it happens and use the debugger window "Call stack". You will see where the calls come from. Find out the reason for infinite recursion and devise a correct condition of exit from recursion. Usually, the bug can be found very quickly if you combine debugging with simple logic.

You make an initial guess on at least one method which is attempted to get called "infinite" number of times. Usually it does not take long to find such place. You put break point(s) on a very beginning of such method(s) and try to confirm it happens. When the execution is stopped on a breakpoint, you can go up the stack or down the stack. It's more effective to go down: you keep the breakpoint and debug just one this method stepwise, making big steps at first, until you catch the same method being called deeper in stack (remember your breakpoint is still there). When it happens, you start over and go in smaller step until you pinpoint where the recursion goes. This time try to figure out why the condition of the recursion end is never met. At the same time you move your breakpoint(s) closer to the source of recursive call, narrowing your net.

It may sound difficult, but with little practice always gives 100% results, unlike the cases with different bugs of some unknown nature. In case of stack overflow, you can be 100% sure that you can find the problem before you start looking.

—SA
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900