title: How to delete data in datagridview and database in other form?
body: <p>I have a serviced-based database Customer. I view its contents in Form1 datagridview.</p>
  
  <p>I made a new Form. Form2 to delete Form1's datagridview contents.</p>
  
  <p>Costumers table has the following columns:</p>
  
  <pre><code>CustomerID, CustomerName, Address, ContactNumber
  </code></pre>
  
  <p>This is the code that i am using and its not working whats wrong?</p>
  
  <pre><code>private void button1_Click(object sender, EventArgs e)
      {
          Database1Entities db1Entities = new Database1Entities();
          var customerToDelete = (from i in db1Entities.Customers
                                  where i.CustomerID == 1201
                                  select i).FirstOrDefault();
          if (customerToDelete != null) 
          {
              db1Entities.Customers.DeleteObject(customerToDelete);
              db1Entities.SaveChanges();
          }
      }   
  </code></pre>