Beispiel #1
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         if (MessageBox.Show("Are you sure you want do add this brand?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             cn.Open();
             cm = new SqlCommand("INSERT INTO tblBrand(Brand) VALUES (@brand)", cn);
             cm.Parameters.AddWithValue("@brand", txtBrand.Text);
             cm.ExecuteNonQuery();
             cn.Close();
             MessageBox.Show("Record has been succesfully saved.");
             Clear();
             frmlist.LoadRecords();
         }
     } catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }