Hi DrPurdum,
In Listing 14-9 in the book, in method DoQuery(), you have the following code:
Code:
try
{
ds = newDataSet(); // Instantiate DataSet object
conn.Open();
command.CommandText = txtQuery.Text;
adapter = newOleDbDataAdapter(command);
adapter.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
command.ExecuteNonQuery();
}
catch (Exception ex)
{
MessageBox.Show("Error: " + ex.Message);
}
finally
{
conn.Close();
}
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.