SQL OleDBCommand selecting Excel Columns

亡梦爱人 提交于 2019-12-11 18:58:37

问题


I'm using OleDBCommand to select some data in an Excel sheet I have. I have One column that has lists of data (column J) and every column after that either (columns K - AG) has a 1 or 0 depending on a relationship. So it's basically a graph plotted with 1 or 0. I want to use a SQL command to select every entry in column J where there is a 1 plotted in a column I choose. For example, say I want to look at the column J to K relationship. Then I would want to pull all data from J where columns J and K have a 1. I am unsure of how to specify columns in SQL. I have currently:

OleDbCommand command = new OleDbCommand("select * from [Master$J0:J20] , connection);

I would need a WHERE clause after that to specify, where K0:K20 = '1' right? Or something like that. I can't get it.


回答1:


Solution: Columns can be referenced by F1, F2, F3...FN. So in my case I would want for example:

SELECT F8 FROM [Sheet1$] WHERE F11 = '1'


来源:https://stackoverflow.com/questions/24294393/sql-oledbcommand-selecting-excel-columns

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!