Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You have defined the adapter variable inside the <code>intSchedular</code> method. But this variable is local to that method and cannot be used outside of it (It will be destroyed when you exit from <code>intSchedular</code>)</p> <p>To be able to use the variable in <code>Storage_AppointmentsModified</code>, you need to define it at the global class scope like you already do with the <code>CarsDBDataSet</code></p> <pre><code>public partial class MainWindow : Window { CarsDBDataSet dataSet; OleDbDataAdapter adapter; ..... private void intSchedular() { ..... adapter = new OleDbDataAdapter(createCommand); ..... } void Storage_AppointmentsModified(object sender, PersistentObjectsEventArgs e) { this.adapter.Update(dataSet); this.dataSet.AcceptChanges(); } </code></pre> <p>Another thing to fix in your code is the Handling of the connection. A Connection should be used following a precise pattern. Create, Open, Use, Close and Destroy. You should be using the using statement in your intSchedular to be sure of the destruction of the connection</p> <pre><code>private void intSchedular() { // CREATE using(OleDbConnection con = new OleDbConnection(... con string here....)) using(OleDbCommand createCommand = new OleDbCommand("select * from CarScheduling", con)) { // OPEN con.Open(); // NO USING HERE BECAUSE WE WANT THE ADAPTER OUTSIDE OF THIS METHOD adapter = new OleDbDataAdapter(createCommand); // USE .... adapter.Fill(dataSet.CarScheduling); .... } // CLOSE + DISPOSE } </code></pre> <p>The same thing should be done in the <code>adapter_RowUpdated</code></p> <pre><code>private void adapter_RowUpdated(object sender, System.Data.OleDb.OleDbRowUpdatedEventArgs e) { if (e.Status == UpdateStatus.Continue &amp;&amp; e.StatementType == StatementType.Insert) { int id = 0; using (OleDbConnection con = new OleDbConnection( .... con string here ....)) using (OleDbCommand cmd = new OleDbCommand("SELECT @@IDENTITY", con)) { con.Open(); id = (int)cmd.ExecuteScalar(); } e.Row["ID"] = id; } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload