日期:2014-05-18  浏览次数:20729 次

在girdview实现删除操作,这些个语法有错误吗?
public void Delete(string code)
  {
  using (OleDbCommand delete = new OleDbCommand())
  {
  delete.CommandText = "delete into country(code) values ('" + code + "')";
  delete.Connection = this.GetConnection();
  try
  {
  delete.Connection.Open();
  delete.ExecuteNonQuery();
  }
  finally
  {
  delete.Connection.Close();
  }
  }
  }


  private void ButtonDelete(object sender, EventArgs e)
  {
  country ct = new country();
  ct.Delete(this.textBox1.Text.Trim()); 
  this.dataGridView1.DataSource = ct.GetCountry().Tables[0]; 
  }



------解决方案--------------------
delete from 表名 where 字段名="条件";