I followed Jim Scott's instruction to read CSV into a DataTable with the following code:
private OleDbConnection CNN = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Directory.GetCurrentDirectory()+";Extended Properties=\"Text;HDR=Yes\"");
private OleDbCommand CMD;
private OleDbDataAdapter ADT;
private DataTable DT=new DataTable();
protected void Page_Load(object sender, EventArgs e)
{
CNN.Open();
CMD = new OleDbCommand(@"select * from [Report.csv]", CNN);
ADT = new OleDbDataAdapter(CMD);
ADT.Fill(DT);
}
I had put the Report.csv under the root directory, and tried following things to no avail!
Changed
Data Sourcetolocalhost,(localhost),~,~\\.Changed
Report.csvtoReport.Finally change
Data SourcetoDirectory.GetCurrentDirectory()to get it to connect correctly.
Problem: It can NOT find Report.csv!
I wish this to be a webpage, so what I need is a way for the
OleDbConnectionconnect tolocalhostand pointed to the root directory!It will be VERY nice if somebody could teach me how to do that!
Somebody please be so kind and tell me where did I do wrong and how to set it up correctly!
Much appreciated!!!