Let's see here. You are accessing an Access database in C# and then you tag your question sql-server-general and dotnet-visual-basic?
Anyway, the normal way to handle connections is to define them in a using block, which guarantees that they are closed and disposed and goes back to the connection pool when you exit the using block. I should hasten to add that this is the normal thing when you connect to SQL Server. Whether there is a connection pool with the OLE DB provider for Access, I don't know.
Here is an untested example of how it would look like:
private void btnTest_Click(object sender, EventArgs e)
{
using (OleDbConnection booksConnection = new OleDbConnection(
@"Provider=Microsoft.ACE.OLEDB.12.0; Data Source = C:\Users\youraccount\access\BooksDB.accdb");
{
// Declare Command, Adapter, DataTable object
OleDbCommand resultsCommand = null;
OleDbDataAdapter resultsAdapter = new OleDbDataAdapter();
DataTable resultsTable = new DataTable();
// Build SQL string
string cmdText = txtSQLTester.Text;
try {
booksCOnnections.open();
// establish command object and data adapter
resultsCommand = new OleDbCommand(cmdText, booksConnection);
resultsAdapter.SelectCommand = resultsCommand; // Error
resultsAdapter.Fill(resultsTable); // Error
// bind grid view to data table
grdSQLTester.DataSource = resultsTable;
lblRecords.Text = resultsTable.Rows.Count.ToString();
}
catch (Exception ex) {
MessageBox.Show(ex.Message, "Error in Processing SQL", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}