[此贴子已经被作者于2007-5-30 12:50:09编辑过]
[此贴子已经被作者于2007-5-30 12:50:09编辑过]
SqlConnection con = DB.CreateConn();
con.Open();
string sqlstr0 = "delete from Teacher_course where Teacher_course.Teacher_id='" + Gv_teach.DataKeys[e.RowIndex].Value.ToString() + "'";
string sqlstr1 = "delete from Teacher where Teacher_id='"+Gv_teach.DataKeys[e.RowIndex].Value.ToString()+"'";
SqlCommand sqlcom0 = new SqlCommand(sqlstr0, con);
sqlcom0.ExecuteNonQuery();
SqlCommand sqlcom1 = new SqlCommand(sqlstr1, con);
sqlcom1.ExecuteNonQuery();
try
{
sqlcom1.ExecuteNonQuery();
Lbl_note.Text = "删除成功";
Lbl_note.Style["color"]="green";
}
catch (SqlException)
{
Lbl_note.Text = "删除失败";
Lbl_note.Style["color"] = "red";
}
sqlcom0.Connection.Close();
sqlcom1.Connection.Close();
St_BindGridView();
多表删除程序与各位讨论一下,能删除但不会执行try语句.有高人指点哈就好了.
[此贴子已经被作者于2007-7-25 20:41:34编辑过]