我嘗試通過下面的代碼過程或函數「批准」預計參數「@ApproveID」,但未提供
if (e.CommandName == "_Approve")
{
//using (SqlConnection con = DataAccess.GetConnected())
using (SqlConnection con = new
SqlConnection(ConfigurationManager.ConnectionStrings["mydms"]
.ConnectionString))
{
try
{
con.Open();
int rowindex = Convert.ToInt32(e.CommandArgument);
GridViewRow row = (GridViewRow)
((Control)e.CommandSource).NamingContainer;
Button Prove_Button = (Button)row.FindControl("BtnApprove");
SqlCommand cmd = new SqlCommand("approve", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@UserID", UserID));
cmd.Parameters.Add(new SqlParameter("@DocID", DocID));
cmd.Parameters.Add(new SqlParameter("@ApproveID", ApproveID));
int result = cmd.ExecuteNonQuery();
if (result != 0)
{
GrdFileApprove.DataBind();
}
}
catch
{
apfi.Text = "Not Approve";
}
finally
{
con.Close();
}
}
}
else if (e.CommandName == "_Reject")
{
using (SqlConnection con = new
SqlConnection(ConfigurationManager.ConnectionStrings
["mydms"].ConnectionString))
{
try
{
con.Open();
int rowindex = Convert.ToInt32(e.CommandArgument);
GridViewRow row = (GridViewRow)
((Control)e.CommandSource).NamingContainer;
LinkButton Prove_Button = (LinkButton)row.FindControl("Button1");
SqlCommand cmd = new SqlCommand("sprejectapprove", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@UserID",UserID));
cmd.Parameters.Add(new SqlParameter("@DocID", DocID));
cmd.Parameters.Add(new SqlParameter("@ApproveID", ApproveID));
int result = cmd.ExecuteNonQuery();
if (result != 0)
{
GrdFileApprove.DataBind();
}
}
catch
{
apfi.Text = "Rejct";
}
finally
{
con.Close();
}
}
}
批准文件和批准存儲過程是
@UserID int,
@DocID int,
@ApproveID int
as
insert into Approval(UserID,DocID,ApproveID)
VALUES(@UserID,@DocID,@ApproveID)
和SQL有審批類型表,其中批准審批類型和批准類型有3種類型1批准2拒絕和3正在審批
並在審批已經桌子上有用戶ID,文檔ID,approveid
因此,當我調試代碼它給我的錯誤在批准部分漁獲
過程或函數「批准」需要參數「@ApproveID」,但未提供。 任何幫助,請 thanku
這是針對本地數據庫或遠程數據庫?本地數據庫爲 – Arran
。 – user2832406
它在哪裏?它是作爲參考附加到項目還是數據庫存在其他地方?你能顯示你的連接字符串嗎? – Arran