How to cleanly update database from Datagridview?

Why would this code not update the local MS Access database?

  • { // // add whiskey from menu string connection = @" Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Database.accdb"; OleDbConnection conn = new OleDbConnection(connection); try { conn.Open(); } catch (Exception) { MessageBox.Show("Did Not Connect"); } OleDbCommand command = new OleDbCommand(); command.CommandType = System.Data.CommandType.Text; command.CommandText = "UPDATE Alcohol SET Quantity = '90000' WHERE Type = 'Whiskey'"; command.Connection = conn; command.ExecuteNonQuery(); Using C# trying to get this to change a field in the database.. it isn't throwing any errors.. but, it isn't changing the database either.. any ideas on how I could get this working right?

  • Answer:

    If it's not throwing any errors then it must not be finding any records that match your criteria. Are you sure that Type would contain "Whiskey" Is it possible that it has another value stored like a key to another file that containes type descriptions?

Nameless at Yahoo! Answers Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.