I'm making a program that adds favourite programs, files and websites to an Oracle database so there is no longer a need to browse my pc to find those files.

I'm stuck on trying to find a way to edit the database and refreshing the program so the edited data shows, trying to type data in a textbox and using a button to update the database.

Any help would be appreciated, and if any info on my code is needed or requested it shall be provided. Please help if you can.

Dani AI

Generated

Since already has the table showing in a DataGridView and buttons that launch programs by the ID column, the quickest reliable approach is either (A) data-bound editing with a DataAdapter/DataTable or (B) an explicit parameterized UPDATE executed when the user clicks Save. asked what exists so the notes below assume a typical .NET + Oracle setup (use Oracle.ManagedDataAccess where possible).

Use a data-bound flow when you want the grid to be editable:

  • Fill a DataTable with an OracleDataAdapter and bind it through a BindingSource to the DataGridView.
  • Let the user edit inline or in TextBoxes bound to the same BindingSource.
  • On save do dataGridView.EndEdit(); bindingSource.EndEdit(); then call dataAdapter.Update(dataTable). Do not call AcceptChanges() before Update — that clears change flags and prevents updates.

Use an explicit UPDATE when you prefer control or a single-row edit form. Example C# pattern (managed ODP.NET):

using Oracle.ManagedDataAccess.Client;

using (var conn = new OracleConnection(connString))
using (var cmd = conn.CreateCommand())
{
    cmd.CommandText = "UPDATE favorites SET name = :name, path = :path WHERE id = :id";
    cmd.Parameters.Add(":name", OracleDbType.Varchar2).Value = txtName.Text;
    cmd.Parameters.Add(":path", OracleDbType.Varchar2).Value = txtPath.Text;
    cmd.Parameters.Add(":id", OracleDbType.Int32).Value = selectedId;
    conn.Open();
    cmd.ExecuteNonQuery();
}

Practical tips and gotchas:

  • Always use parameterized SQL (no string concatenation) and wrap DB work in try/catch; dispose connections with using.
  • If updates from other apps must appear while your program runs, either poll the DB on a short timer or use Oracle Continuous Query Notification (CQN) for push updates (CQN needs DB support and privileges).
  • If an UPDATE affects 0 rows, check your WHERE clause, parameter names/types, and whether you committed the transaction.
  • Common mistakes: UpdateCommand not set on the adapter, AcceptChanges() called too early, DataGridView bound to a copy (DefaultView issues), or ReadOnly columns blocking edits.

Recommended Answers

All 2 Replies

What do you have so far?

What do you have so far?

The database shows up in my datagridview, I have a few buttons that execute a program from the "ID"row of my database, I can link the code tomorrow was I do not have it with me at the moment.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.