我在 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;
}