URGENT : PB Delete Row in Northwind.mdb

From: ptreves (ptreves_at_sympatico.ca)
Date: 03/25/04


Date: Thu, 25 Mar 2004 09:21:06 -0800

Hello,

I am writing as ASP.NET application using a DataGrid Web COntrol.
I included a Delete, Edit/Update/Cancel, Select button columns to my DataGrid.

When I click the Delete button, I trap the event.
My code however does not delete the selected row.

Here is my sample Delete function :
-----
                private void deleteRow(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
                {
                        try
                        {
                                ErrorMessage.Text = "";
                                OleDbCommand delCommand = new OleDbCommand();
                                delCommand.Connection = oleDbConnection1;
                                delCommand.CommandText = "DELETE FROM Customers " +
                                                "WHERE CutomerID = '" + e.Item.Cells[9].Text + "'";
                                delCommand.CommandType = CommandType.Text;
                                oleDbConnection1.Open();
                                delCommand.ExecuteNonQuery();
                                oleDbDataAdapter1.Fill(dataSet11);
                                Cache["CustomerData"] = dataSet11;
                                bindGrid();
                                oleDbConnection1.Close();
                        }
                        catch (Exception ex)
                        {
                                ErrorMessage.Text = ex.Message;
                        }
                }
-----

Any feedback is appreciated,

Regards,

Paolo