fegdvbna22
Programmer
I'm using this code to obtain a dataset from a csv file. What do I need to change to obtain a dataset from an excel file?
public DataTable GetCSVDataSet(string strCheckFile)
{
string connString =
string.Format(
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=Text;",
Path.GetDirectoryName(strCheckFile));
string cmdString =
string.Format("SELECT * FROM {0} ", Path.GetFileName(strCheckFile));
DataTable dt = new DataTable();
using (OleDbConnection conn = new OleDbConnection(connString))
{
conn.Open();
OleDbDataAdapter adapter = new OleDbDataAdapter();
adapter.SelectCommand = new OleDbCommand(cmdString, conn);
adapter.Fill(dt);
}
return dt;
}
public DataTable GetCSVDataSet(string strCheckFile)
{
string connString =
string.Format(
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=Text;",
Path.GetDirectoryName(strCheckFile));
string cmdString =
string.Format("SELECT * FROM {0} ", Path.GetFileName(strCheckFile));
DataTable dt = new DataTable();
using (OleDbConnection conn = new OleDbConnection(connString))
{
conn.Open();
OleDbDataAdapter adapter = new OleDbDataAdapter();
adapter.SelectCommand = new OleDbCommand(cmdString, conn);
adapter.Fill(dt);
}
return dt;
}