读取csv文件

            String sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\\test\\;Extended Properties='text;HDR=No;FMT=Delimited'";

            OleDbConnection objConn = new OleDbConnection(sConnectionString);

            objConn.Open();

            DataTable dt = new DataTable();

            OleDbCommand objCmdSelect = new OleDbCommand("SELECT * FROM test.csv", objConn);

            OleDbDataAdapter objAdapter1 = new OleDbDataAdapter();

            objAdapter1.SelectCommand = objCmdSelect;

            objAdapter1.Fill(dt);

            objConn.Close();

 

你可能感兴趣的:(csv)