DataAdapter for CSV files

Cathi Gero posted some code that allows you work with CSV files using CSVDataAdapter . Nice job!

To read the contents of a CSV file:

CSVDataAdapter CSVda = new CSVDataAdapter(@"c:\MyFile.csv");
CSVda.HasHeaderRow = true;
DataSet ds = new DataSet();
CSVda.Fill(ds);
 

To write to a CSV file:

CSVDataAdapter CSVda = new CSVDataAdapter(@"c:\MyFile.csv");
bool InclHeader = true;
CSVda.Update(MyDataSet,"MyTable",InclHeader);
 

 
 
 

Leave a Reply