开发者

Query Excel using ADO from VB.NET when a column name is a number

I am using VB.NET to query via SQL an Excel spreadsheet using ADO.

The general way is like this:

SELECT [firstname], [secondname] FROM [Sheet1$]

Which works perfectly

However, one of the headings is called 3, so I want to do:

SELECT [firstname], [secondname], [3] FROM [Sheet1$]

However, this does not work. I know I can use * to get all columns, but later on I want to use (using dataReader):

dr("3") which won't work

Any开发者_JAVA百科 ideas?


When using (or implying) HDR=YES in the connection string, an illegal column name will be replaced with the column's ordinal position appended with the letter F.

For example, if your column named 3 is the fifth column in the Excel Range then its name will be considered to be F5.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜