I know that to instantiate a new OLEDbCommand object you do this:
OleDbCommand command = new OleDbCommand(queryString, connection);
However, I am confused as to what this line of code is doing:
OleDbCommand cmd = aConnection.CreateCommand();
I know that aConnection is an OleDbConnection object which was instantiated earlier in the code.
From the MSDN Library I know that CreateCommand() is an OdbcCommand object associated with the OdbcConnection. However, the Library doesn’t really go any further to explain its purpose.
Even though I know what the individual components are, I am unsure of what is happening here. Is cmd an OleDbCommand object that is being instantiated in order to be able to use SQL commands? I infer this because further on in the code there is the following:
cmd.CommandText = "SELECT * FROM Team where typeOfSport = '" + typeOfSport + "'";
It is just creating a command from the connection object. The command will be associated with the connection it was created from.
is the same as