private void btnChange_Click(object sender, EventArgs e) { string sqlcmd = "update book set title='{0}',author='{1}',press='{2}',num='{3}',ramined='{4}',place='{5}' where id='{6}'"; sqlcmd = string.Format(sqlcmd, txtName.Text.ToString(), txtAuthor.Text.ToString(), txtPress.Text.ToString(), txtNum.Text.ToString(), txtRemained.Text.ToString() , txtPlace.Text.ToString(), id); Console.WriteLine(sqlcmd); if (MysqlUtil.operation(sqlcmd) == -1) { MessageBox.Show("更新时发生了未知错误,请重试", "error", MessageBoxButtons.OK); } else { MessageBox.Show("修改成功"); this.DialogResult = DialogResult.OK; this.Close(); superForm.Reload(); } }
private void btnChange_Click(object sender, EventArgs e) { string title = txtName.Text.ToString(); string author = txtAuthor.Text.ToString(); string press = txtPress.Text.ToString(); string num = txtNum.Text.ToString(); string remained = txtRemained.Text.ToString(); string place = txtPlace.Text.ToString(); string sqlcmd = "INSERT INTO book (title, author, press, num, ramined, place) VALUES ('{0}','{1}','{2}','{3}','{4}','{5}')"; sqlcmd = string.Format(sqlcmd, title, author, press, num, remained, place); Console.WriteLine(sqlcmd); if (MysqlUtil.operation(sqlcmd) == -1) { MessageBox.Show("插入时发生了未知错误,请重试", "error", MessageBoxButtons.OK); } else { MessageBox.Show("插入成功"); this.DialogResult = DialogResult.OK; this.Close(); superForm.Reload(); } }