所以,我试图删除一行,但它一直出现
我的代码是
private void btnDelete_Click(object sender, EventArgs e)
{
if (dtgAccs.Rows.Count > 1)
{
if (dtgAccs.CurrentRow.Index == dtgAccs.Rows.Count - 1)
{
MessageBox.Show("Please re-select rows.");
}
else
{
if (DialogResult.Yes == MessageBox.Show(("Delete Account?"), "Message", MessageBoxButtons.YesNo))
{
dtgAccs.Rows.RemoveAt(dtgAccs.CurrentRow.Index);
db.execSQL("DELETE from Accounts WHERE ID='" + IDa + "'AND Full_Name ='" + FullN + "'AND Email ='"
+ Emaila + "'AND User_name ='" + Usernamea + "'AND Pass_word ='" + Passworda + "'AND Position_a ='" + Positiona + "'" );
MessageBox.Show("Account has been deleted.");
}
}
}
else
{
MessageBox.Show("No Account to delete.");
}
}
我是一个新手和idk,XD如何帮助我呢?提前致谢
BTW XD如果你有一个代码示例给我看或编辑我的代码,我们将不胜感激。作为一个新手huhuhu sprry
答案 0 :(得分:0)
我现在得到了答案。感谢我的导师帮助我做什么做XD
if (DialogResult.Yes == MessageBox.Show(("Delete Account?"), "Message", MessageBoxButtons.YesNo))
{
int userId = Convert.ToInt32(dtgAccs.Rows[dtgAccs.CurrentRow.Index].Cells[0].Value);
Console.Write(userId);
db.execSQL("DELETE from Accounts WHERE ID=" + userId);
dtgAccs.Rows.RemoveAt(dtgAccs.CurrentRow.Index);
MessageBox.Show("Account has been deleted.");
}
你只需要制作一个变量并转换它:)希望这对其他人也有帮助