>>I'm assuming the DataSet object is some sort of factory for producing objects of type Date, Integer, String, etc - correct?
No. A DataSet is a built in .NET object that is really an in-memory table (or tables) of data. All step 3 does is gives me the collection of data in-memory to manipulate and introduce any business logic.
It works like this:
Code:
OleDbConnection excelConnection = new OleDbConnection(
"Provider=Microsoft.Jet.Oledb.4.0;" +
"Data Source=" + Server.MapPath(fullPath) + ";" + // path to location where I saved the file
"Extended Properties=\"Excel 8.0;HDR=Yes;\"");
OleDbCommand cmd = new OleDbCommand(
@"SELECT * FROM [NameOfSpreadsheet$]", excelConnection);
OleDbDataAdapter adapter = new OleDbDataAdapter();
adapter.SelectCommand = cmd;
DataSet data = new DataSet();
adapter.Fill(data);
Where "data" is now an in-memory table that can be accessed like:
Code:
foreach(DataRow dr in data.Tables[0].Rows)
{
// Business logic would go here...
Of course, this is how Excel spreadsheets are handled. CSVs and XML files would be naturally handled differently. But putting them into a DataSet object as well would be desirable, so the business logic plug in would always be introduced in the same portion of the code