내 페이지에 Gridview가 있습니다 어느 행을 선택할 수 있습니까? Gridview에서 행을 선택하고 `단순 테이블에서 삭제하지만이 오류가 있습니다 "스케이프 변수"@Senduserid "를 선언해야합니다"
public bool Delete(int Id)
{
using (SqlCommand cmd = new SqlCommand())
{
string text = string.Format("Delete From {0} where {1} = @{1} or {2} [email protected]{2}"
, Common.Data.MessageInfo.TableName
, Common.Data.MessageInfo.SenduseridField
,Common.Data.MessageInfo.RecuseridField);
cmd.CommandText = text;
SqlParameter param = new SqlParameter("@" + Common.Data.MessageInfo.SenduseridField, Id);
param.SqlDbType = SqlDbType.Int;
param = new SqlParameter("@" + Common.Data.MessageInfo.RecuseridField, Id);
param.SqlDbType = SqlDbType.Int;
cmd.Parameters.Add(param);
cmd.Connection = this.GetConnection();
cmd.Connection.Open();
cmd.ExecuteNonQuery();
return true;
}
}
: 여기에 나는이 오류가있어 장소의 삭제 버튼 코드
protected void btnMultipleRowDelete_Click(object sender, EventArgs e)
{
// Looping through all the rows in the GridView
foreach (GridViewRow row in GridView1.Rows)
{
CheckBox checkbox = (CheckBox)row.FindControl("chkRows");
//Check if the checkbox is checked.
//value in the CheckBox's Value property is set as the //value of the delete command's parameter.
while (checkbox.Checked)
{
// Retreive the ID
int ida = Convert.ToInt32(GridView1.DataKeys[row.RowIndex].Value);
// Pass the value of the selected Employye ID to the Delete
//These numbers indicate in which order tables shoulde be deleted
/*1*/
new BLL.LoginBLL().Delete(ida);
/*2*/
new BLL.MessageBLL().Delete(ida);
/*3*/
new BLL.JointBLL().Delete(ida);
/*4*/
new BLL.Tempprice().Delete(ida);
/*5*/
new BLL.LotsBLL().Delete(ida);
/*6*/
new BLL.AuctionBLL().Delete(ida);
/*7*/
new BLL.ProfileBLL().DeleteProfile(ida);
checkbox.Checked = false;
}
//refresh the Gridview rows
ShowUsers();
}
}
그리고 코드의이 오류 가 @Senduserid "" "스칼라 변수를 선언해야"삭제 버튼 igot 클릭
데이터베이스 관계
나는 바보입니다. –