I was going thru some client code and I found some code like this:
OracleDataAdapter dataadapter = new OracleDataAdapter(sqlString, connection); DataTable dtResult = new DataTable(); dataadapter.Fill(dtResult); connection.Close();
I really don't like that code. Because what happens if you change you database from Oracle to SQL Server, that might mean tons of changes.
I prefer to use code based on the
System.Data.Common namespace. Something require a little extra lines but your code will adapt easier to different databases.
var adapter = providerFactory.CreateDataAdapter(); var command = providerFactory.CreateCommand(); command.CommandText = sqlString; command.Connection = (DbConnection)conn; adapter.SelectCommand = command; var dtResult = new DataTable(); adapter.Fill(dtResult); connection.Close();