In Listing 14-9 in the book, in method DoQuery(), you have the following code:
ds = newDataSet(); // Instantiate DataSet object
command.CommandText = txtQuery.Text;
adapter = newOleDbDataAdapter(command);
dataGridView1.DataSource = ds.Tables;
catch (Exception ex)
MessageBox.Show("Error: " + ex.Message);
I wonder why you use the command.ExecuteNonQuery()
statement. As far as I can tell, the adapter.Fill(ds)
already executes the SQL statement and fills the dataset.
In the book, you say that the call to Fill
just passes the dataset and the ExecuteNonQuery
executes the actual query. That is not what I see when debugging the code. Once the Fill
has been executed, the DataSet contains a table with several rows in it.