-1
刪除數據DeleteButton代碼我有一個表格名「AddNewUnitForm」通過這個我在SQL Server數據庫中保存的數據。通過DataGridView中的選擇數據請忠告「DeleteButton」代碼刪除從數據庫中的數據
SaveButton
碼作爲下參考
string connString = ConfigurationManager.ConnectionStrings["dbx"].ConnectionString;
using (SqlConnection conn = new SqlConnection(connString))
{
using (SqlCommand cmd = new SqlCommand("usp_UnitMasterInsertDetails", conn))
{
cmd.CommandType = CommandType.StoredProcedure;
//Parameter
cmd.Parameters.AddWithValue("UNITNAME", AddUnitTextBox.Text);
//Open Connection
conn.Open();
// ExecuteReader (Select Statement)
// ExecuteScalar (Select Statement)
// ExecuteNoQuery (Insert, Update or Delete)
cmd.ExecuteNonQuery();
MessageBox.Show("ADDED SUCCESSFULLY", "Succesful", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
由於當改變標誌.......我做到了通過存儲過程及其工作 –