代码
file="c:\\temp\test.csv";
DataSet ds = new DataSet();
string filePath = file.Substring(0, file.LastIndexOf("\\") + 1);
using (OleDbConnection conn = new OleDbConnection(string.Format(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties='Text;'", filePath)))
{
OleDbDataAdapter adp = new OleDbDataAdapter(string.Format("SELECT * FROM [{0}]", file.Replace(filePath, "")), conn);
try
{
adp.Fill(ds, "clbm");
}
catch
{
}
}
DataSet ds = new DataSet();
string filePath = file.Substring(0, file.LastIndexOf("\\") + 1);
using (OleDbConnection conn = new OleDbConnection(string.Format(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties='Text;'", filePath)))
{
OleDbDataAdapter adp = new OleDbDataAdapter(string.Format("SELECT * FROM [{0}]", file.Replace(filePath, "")), conn);
try
{
adp.Fill(ds, "clbm");
}
catch
{
}
}