0

我在 ASP.NET 3.5 中使用 MVC 架构。在编辑中,我收到上述错误。

1)我使用了存储过程:

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)这是我在 DAL 类文件中的函数:

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)这个在BAL类文件中

    public DataSet editp(BOParty pcode, BOParty PName, BOParty Tel)
    {
        DataSet ds = new DataSet();
        ds = new DataSet();
        ds = editp(pcode, PName, Tel);
        return ds;
    }

4) 这是在 .cs 文件中:

    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;

    }
4

2 回答 2

1

editp在突出显示的行中查看您的函数:

public DataSet editp(BOParty pcode, BOParty PName, BOParty Tel)
{
    DataSet ds = new DataSet();
    ds = new DataSet();
    ds = editp(pcode, PName, Tel); // <--- HERE
    return ds;
}

editp递归调用然后它会导致StackOverflowException. 我想你想editp在 DAL 类中调用方法,但是你editp一次又一次地调用相同的方法。

于 2012-06-27T11:10:08.987 回答
0

3)这个在BAL类文件中

  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;
    }
于 2012-06-27T11:22:13.800 回答