Reputation: 405
I m using MVC architecture in ASP.NET 3.5. In edit I'm getting the above error.
1) I have used stored procedure:
ALTER PROCEDURE [dbo].[editparty]
(
@pcode nvarchar(50),
@cname nvarchar(100),
@cont nvarchar(50)
)
AS
update tbl_party set party_name=@cname,party_code = @pcode,party_contact =@cont where party_id=(Select party_id from tbl_party where party_code = @pcode)
2) This is my function in DAL class file:
public DataSet editp(BOParty pcode, BOParty PName, BOParty Tel)
{
OpenCnn();
SqlCommand cmd = new SqlCommand("editparty", cnn);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter[] par = { new SqlParameter("@pcode", pcode.pcode), };
cmd.Parameters.AddRange(par);
SqlParameter[] nm = { new SqlParameter("@PName", pcode.pcode), };
cmd.Parameters.AddRange(nm);
SqlParameter[] tl = { new SqlParameter("@Tel", pcode.pcode), };
cmd.Parameters.AddRange(tl);
SqlDataAdapter ad = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
ad.Fill(ds);
return ds;
CloseCnn();
}
3)this in in BAL class file
public DataSet editp(BOParty pcode, BOParty PName, BOParty Tel)
{
DataSet ds = new DataSet();
ds = new DataSet();
ds = editp(pcode, PName, Tel);
return ds;
}
4) This is in .cs file:
protected void edit_Click(object sender, EventArgs e)
{
pcode.pcode = txtpcde.Text;
pcode.Tel= txtcont.Text;
pcode.PName = txtcname.Text;
DataSet ds = new DataSet();
ds = new DataSet();
ds = pcode.editp(pcode, PName, Tel);
edit.Enabled = false;
}
Upvotes: 0
Views: 2737
Reputation: 405
3)this in in BAL class file
public DataSet editp(BOParty pcode, BOParty PName, BOParty Tel)
{
DataSet ds = new DataSet();
ds = new DataSet();
ds = party.editp(pcode, PName, Tel);<------ party is object of DAL class file( private DAParty partydata;)--------------
return ds;
}
Upvotes: 0
Reputation: 67090
Look your editp
function at the highlighted line:
public DataSet editp(BOParty pcode, BOParty PName, BOParty Tel)
{
DataSet ds = new DataSet();
ds = new DataSet();
ds = editp(pcode, PName, Tel); // <--- HERE
return ds;
}
You call editp
recursively then it'll cause StackOverflowException
. I think you would like to call editp
method in the DAL class but there you're calling the same editp
method again and again.
Upvotes: 1