日期:2014-05-20 浏览次数:21109 次
conn = new SqlConnection(SQL.conStr); conn.Open(); int row = this.dataGridView2.CurrentCell.RowIndex; if (dataGridView2.CurrentRow != null) { if (MessageBox.Show("确定要删除该行数据吗?", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { try { string ind = this.dataGridView2.Rows[row].Cells["流程环节编号"].Value.ToString(); string inds = this.dataGridView2.Rows[row].Cells["主机型号"].Value.ToString(); SqlCommand cmDelete = new SqlCommand("delete from hostmodel_process where process_id = '" + ind + "' and host_model='"+inds+"'", conn); cmDelete.ExecuteNonQuery(); MessageBox.Show("删除成功!"); string sql = "select host_model as 主机型号,process_id as 流程环节编号 from hostmodel_process order by host_model,process_id asc"; SDA1 = new SqlDataAdapter(sql, conn); DT1 = new System.Data.DataTable(); SDA1.Fill(DT1); this.dataGridView2.DataSource = DT1; cmDelete.Dispose(); conn.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } }