0

这是我的代码

OleDbCommand cmdExcel = new OleDbCommand();
OleDbDataAdapter oda = new OleDbDataAdapter();
DataTable dtable = new DataTable();
cmdExcel.CommandText = SELECT Name,EmailID,PhoneNumber  From [Sheet1$]
oda.SelectCommand = cmdExcel;
oda.Fill(dtable);

这个工作正常但是

SELECT Name,EmailID,Phone Number From [Sheet1$] ... 不工作

我正在尝试使用 [Sheet1$] 中的 SELECT "Name","EmailID","Phone Number" 但无法正常工作...

4

1 回答 1

2

尝试这个

  cmdExcel.CommandText = "SELECT Name,EmailID,PhoneNumber AS [Phone Number]  
  FROM [Sheet1$]";

或者

   cmdExcel.CommandText = "SELECT Name,EmailID,[Phone Number] AS PhoneNumber  
   FROM [Sheet1$]";
于 2012-09-17T07:47:16.280 回答