Friday, May 7, 2010

Read CSV with oledb to dataset - datatable

string csvDirectory = Server.MapPath("~/media/");
        string CsvFile = "SampleDirectory.csv";
        DataSet ds = new DataSet();
        OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + csvDirectory + ";Extended Properties='text;HDR=Yes;FMT=Delimited'");
        OleDbDataAdapter ExcelAdapter = new OleDbDataAdapter("SELECT * FROM " + CsvFile, con);
        con.Open();
        ExcelAdapter.Fill(ds);
        con.Close();
        GridView1.DataSource = ds;
        GridView1.DataBind();

1 comment:

  1. Emperor Casino - Shootercasino.com
    If you are interested in gambling, you are in the right place. 메리트 카지노 주소 For those 제왕카지노 looking to bk8 try an online casino you will find Emperor Casino online.

    ReplyDelete