Rivaldo Grenz

Rivaldo Grenz

  • NA
  • 8
  • 53.8k

Update Access Database from Textbox and fetch data from acces to textbox in C#?

Sep 29 2010 1:02 PM
Hello, I just starting using C# and I have a textbox on a form. I want to retrieve data from the acces database and display to the texbox, and then that the user modify something in the textbox and with a button Update, update the database. I have the code for conecction to acces. Maybe someone has a good example for me, thanks. I hope you can help me


this is my code

 using (var conn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Policias.accdb"))

            using (var cmd = conn.CreateCommand())
            {

                cmd.CommandText = "SELECT contain from section ";
                cmd.Parameters.
                conn.Open();
                cmd.ExecuteNonQuery();


                int rowsAffected = cmd.ExecuteNonQuery();
                if (rowsAffected == 1)
                {
                    MessageBox.Show("Success");
                }
                else
                {
                    MessageBox.Show(string.Format("{0} Rows Affected", rowsAffected));
                }
            }