开发者

Problem with table names in excel with oledb driver

I am using Oledb driver to load data from excel for displaying in tabcontrol with datargids

I am using following loop to load data from every sheet

foreach (string str in sheets)
                {

                    string query = "SELECT * FROM [" + str + "]";


                    adapter.SelectCommand.CommandText = query;
                    adapter.Fill(ds,str);
                }

It works well until sheet names start with numbers. I have a excel file whose sheet name is 26203 REV C (EVK). It throws me error as The Microsoft Jet database engine could not find开发者_StackOverflow the object ''26203 REV C [EVK]$'_'. Make sure the object exists and that you spell its name and the path name correctly.What can be the remedy to the problem. I do not have any control over the sheet names.


Try using backticks (`) instead of brackets:

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

Remember that you also need to include the dollar symbol suffix when selecting.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜