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
{
}
}
本文转自94cool博客园博客,原文链接:http://www.cnblogs.com/94cool/archive/2010/12/24/1915781.html,如需转载请自行联系原作者