SQL OleDBCommand选择Excel列 [英] SQL OleDBCommand selecting Excel Columns

查看:89
本文介绍了SQL OleDBCommand选择Excel列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用OleDBCommand在我拥有的Excel工作表中选择一些数据.我有一列包含数据列表的列(J列),此后的每一列(列K-AG)根据关系具有1或0.因此,它基本上是一个用1或0绘制的图形.我想使用SQL命令选择J列中的每个条目,在我选择的列中绘制了1.例如,假设我要查看列J与K的关系.然后,我想从J中提取所有数据,其中J和K列的值为1. 我不确定如何在SQL中指定列.我目前有:

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);

在那之后我需要一个WHERE子句来指定,其中K0:K20 ='1'对吗?或类似的东西.我听不懂

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

推荐答案

解决方案:列可以由F1,F2,F3 ... FN引用.因此,以我为例,例如:

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'

这篇关于SQL OleDBCommand选择Excel列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆