代码之家  ›  专栏  ›  技术社区  ›  Xinus

excel中带有oledb驱动程序的表名有问题

  •  0
  • Xinus  · 技术社区  · 16 年前

    我正在使用Oledb驱动程序从excel加载数据,以便使用datargids在tabcontrol中显示

    foreach (string str in sheets)
                    {
    
                        string query = "SELECT * FROM [" + str + "]";
    
    
                        adapter.SelectCommand.CommandText = query;
                        adapter.Fill(ds,str);
                    }
    

    在图纸名称以数字开头之前,它工作正常。我有一个excel文件,其工作表名称为 26203 REV C (EVK) The Microsoft Jet database engine could not find the object ''26203 REV C [EVK]$'_'. Make sure the object exists and that you spell its name and the path name correctly. 有什么办法可以解决这个问题。我无法控制图纸名称。

    1 回复  |  直到 16 年前
        1
  •  1
  •   Richard Szalay    16 年前

    尝试使用反勾号(`)而不是括号:

    SELECT * FROM `26203 REV C (EVK)$`
    

    请记住,选择时还需要包括美元符号后缀。

    推荐文章