string connectionString="..."
SqlConnection sqlCon = new SqlConnection(connectionString);
SqlCommand sqlCmd = sqlCon.CreateCommand();
sqlCmd.CommandType = CommandType.StoredProcedure;
sqlCmd.CommandText = "...";
SqlParameter sqlPar = sqlCmd.CreateParameter();
sqlPar.ParameterName = "...";
DO :
string connectionString="..."
IDbCommand dbCmd = dbCon.CreateCommand();
dbCmd.CommandType = CommandType.StoredProcedure;
dbCmd.CommandText = "...";
dbPar.ParameterName = "...";
The goal of this is to limit the amount of provider-specific code.
If you want to adapt this code for any other provider (OleDb, ODBC, Oracle,...) , you only have to change it in 1 place.
Mmm. This is what M$ recommends.
Maybe I should do some test with it to see whether there are any perfs impact...
Maybe more on that someday...