Israel

Israel

  • NA
  • 1.3k
  • 205.4k

Problem with my save dialog logic

May 24 2018 12:17 PM
Hi,
 
The code that you see its help to remove (ou delete) one column. Its works fine.
 
But the problem is I need to put a condition save logic. Its should show a dialog that allow if or not possible to save. Its show this dialog message but when I click yes its display this message error: Additional information: object reference not defined for instance object
  1. private void btnDelete_Click(object sender, EventArgs e)  
  2. {  
  3. if (conn.State != ConnectionState.Open)  
  4. conn.Open();  
  5. OleDbCommand cmd = new OleDbCommand();  
  6. comm.Connection = conn;  
  7. if (MessageBox.Show("Are you sure to save?""Save window", MessageBoxButtons.YesNo) == DialogResult.Yes)  
  8. {  
  9. try  
  10. {  
  11. cmd = new OleDbCommand("ALTER TABLE Billing DROP COLUMN ID ", conn);  
  12. comm.ExecuteNonQuery();  
  13. }  
  14. Finally  
  15. {  
  16. conn.Close();  
  17. }  
  18. }  
  19. }

Answers (1)