Instead of reaching into the command to get the connection, you should create a connection and pass it to the command. That way, they are separate and the connection is not dependent on the life of the command.
If you're doing more than one type of command, this is absolutely necessary.
Otherwise, it's just good practice.
static void Main(string args)
OleDbConnectionStringBuilder csb = new OleDbConnectionStringBuilder()
//fill connection stuff here
using(OleDbConnection conn = new OleDbConnection(csb.ToString()))
string strSQL = "/*some select command*/";
// Do select command (passing connection to the command)
using(OleDbDataReader rdr = (new OleDbCommand(strSQL, conn)).ExecuteReader())
// pass variables from rdr to variables
// Do update command (passing same connection to the command)
// Do insert command (passing same connection to the command)
Also, if you ever want to use transactions, you'll need the connection to be maintained outside of any commands.
For Each ctrl As Control In Me.Controls("pnlMainPanel").Controls
If ctrl.GetType Is GetType(System.Windows.Forms.Panel) Then
For Each subCtrl As Control In ctrl.Controls
If subCtrl.GetType Is GetType(System.Windows.Forms.TextBox) Then
If subCtrl.GetType Is ...