日期:2014-05-18 浏览次数:20991 次
public DataTable GetExcelConnect(string p_dataPath,string p_Filename) { try { string path = @"E:\Documents and Settings\Administrator\桌面\DQUOT20120224\DQUOT\bin\Debug\"; string strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + ";Extended Properties=\"Text;HDR=Yes;FMT=Delimited\""; OleDbConnection myConnect = new OleDbConnection(strCon); if (myConnect.State == ConnectionState.Closed) { myConnect.Open(); } string strCommand = "select * from 17.txt"; OleDbDataAdapter myCommand = new OleDbDataAdapter(strCommand, myConnect); DataSet myDataSet = new DataSet(); DataTable dataTable = new DataTable(); myCommand.Fill(dataTable); if (myConnect.State == ConnectionState.Open) { myConnect.Close(); } return dataTable; } catch (Exception ex) { return null; } }