Could someone advise where I'm going wrong, I get an error message saying "Input string not in the correct format".
Here is the code that is giving the problems.
Thanks
Regards
Lemmo
// Create database connection
thisConnection.Open(); // Create Adapter
OleDbDataAdapter thisAdapter = new OleDbDataAdapter("SELECT CustomerID, Customer, ContactName, TelephoneNo, EmailAddress, Add1, Add2, Add3, Add4, PostCode FROM Customers", thisConnection); // Create builder to build SQL commands
OleDbCommandBuilder thisBuilder = new OleDbCommandBuilder(thisAdapter); // Create Dataset for data tables
DataSet thisDataSet = new DataSet(); // Fill data adapter
thisAdapter.Fill(thisDataSet, "Customers"); // Define primary key
DataColumn[] Keys = new DataColumn[1];
Keys[0] = thisDataSet.Tables["Customers"].Columns["CustomerID"];
thisDataSet.Tables["Customers"].PrimaryKey = Keys; // Find row containing record to be deleted. TextBox1.text contains the name of the customer to be deleted
DataRow findRow = thisDataSet.Tables["Customers"].Rows.Find(textBox1.Text); if (findRow != null)
{
MessageBox.Show("Deleting: {0}",textBox1.Text);
findRow.Delete();
thisAdapter.Update(thisDataSet, "Customers");
}
else
{
MessageBox.Show("Record Not In The Database");
}
thisConnection.Close();
Replies
Know the answer? Post it — somebody with the same question will find it here.