我可以用C#做这个吗? [英] Can I do this in C#?
问题描述
我正在编写一个C#程序来读取一个名为
LocationDetail的Access数据库表。此表由两列组成:位置,
DiscDate。它看起来像这样:
0000001234 122590
0000001234 102207
0000001234 000000
1237847623 102207
1237847623 071395
4545454545 031206
4545454545 000000
等......
第一列表示一个位置,第二列表示断开日期。
如果
日期为'000000'',则表示该位置处于活动状态。所以,这意味着
上面的位置0000001234是一个当前活动的位置,其中两个
之前断开连接。
我是什么我想要做的就是通过这个表,并且只能''获取'没有DiscDate为'000000'的
位置。在这个例子中,
查看上面的数据,我只想要位置1237847623因为
它是唯一没有DiscDate的位置等于
''000000''。它有两个条目,两个条目都有一个有效的断开日期。
这意味着这个位置仍然是无效的。这就是我想要找到的b $ b:所有不活动的位置。
我的C#程序目前将整个LocationDetail表加载到
中程序中的
数据集。我假设我必须使用类似SQL的
命令来操作此数据集,并从中仅拉出我需要的位置
。但是,我不知道该怎么做。有人可以给我看一个
的例子吗?
谢谢,
Kevin
I''m writing a C# program to read from an Access database table called
LocationDetail. This table is made up of two columns: Location,
DiscDate. It looks like this:
0000001234 122590
0000001234 102207
0000001234 000000
1237847623 102207
1237847623 071395
4545454545 031206
4545454545 000000
and so on...
The first column denotes a location, the second a disconnect date.
If
the date is ''000000'' that means the location is active. So, that means
that location 0000001234 above is a currently active location with two
previous disconnects.
What I''d like to do is go through this table and only ''fetch'' the
locations that do not have a DiscDate of ''000000''. In this instance,
looking at the data above, I''d only want location 1237847623 because
it is the only location that doesn''t have a DiscDate that is equal to
''000000''. It has two entries and both have a valid disconnect date.
That means that this location is still "inactive" and that''s what I
want to find: All inactive locations.
My C# program currently loads the entire LocationDetail table into a
dataset in the program. I''m assuming that I have to use SQL-like
commands to act on this dataset and pull only the locations I require
from it. But, I have no idea how to do that. Can someone show me an
example?
Thanks,
Kevin
推荐答案
ke ************ @ gmail .com 写道:
我正在写一个C#程序来读取一个名为
LocationDetail的Access数据库表。此表由两列组成:位置,
DiscDate。它看起来像这样:
0000001234 122590
0000001234 102207
0000001234 000000
1237847623 102207
1237847623 071395
4545454545 031206
4545454545 000000
等......
第一列表示一个位置,第二列表示断开日期。
如果
日期为'000000'',则表示该位置处于活动状态。所以,这意味着
上面的位置0000001234是一个当前活动的位置,其中两个
之前断开连接。
我是什么我想要做的就是通过这个表,并且只能''获取'没有DiscDate为'000000'的
位置。在这个例子中,
查看上面的数据,我只想要位置1237847623因为
它是唯一没有DiscDate的位置等于
''000000''。它有两个条目,两个条目都有一个有效的断开日期。
这意味着这个位置仍然是无效的。这就是我想要找到的b $ b:所有不活动的位置。
我的C#程序目前将整个LocationDetail表加载到
中程序中的
数据集。我假设我必须使用类似SQL的
命令来操作此数据集,并从中仅拉出我需要的位置
。但是,我不知道该怎么做。有人能给我看一个
的例子吗?
I''m writing a C# program to read from an Access database table called
LocationDetail. This table is made up of two columns: Location,
DiscDate. It looks like this:
0000001234 122590
0000001234 102207
0000001234 000000
1237847623 102207
1237847623 071395
4545454545 031206
4545454545 000000
and so on...
The first column denotes a location, the second a disconnect date.
If
the date is ''000000'' that means the location is active. So, that means
that location 0000001234 above is a currently active location with two
previous disconnects.
What I''d like to do is go through this table and only ''fetch'' the
locations that do not have a DiscDate of ''000000''. In this instance,
looking at the data above, I''d only want location 1237847623 because
it is the only location that doesn''t have a DiscDate that is equal to
''000000''. It has two entries and both have a valid disconnect date.
That means that this location is still "inactive" and that''s what I
want to find: All inactive locations.
My C# program currently loads the entire LocationDetail table into a
dataset in the program. I''m assuming that I have to use SQL-like
commands to act on this dataset and pull only the locations I require
from it. But, I have no idea how to do that. Can someone show me an
example?
只将相关数据加载到DataSet中。
类似于:
选择位置,弃置
来自yourtable
WHERE位置不在(选择位置从yourtable WHERE
discdate =''000000'')
Arne
Only load the relevant data into the DataSet.
Something like:
SELECT location,discdate
FROM yourtable
WHERE location NOT IN (SELECT location FROM yourtable WHERE
discdate=''000000'')
Arne
5月25日晚上9:37,Arne Vajh?j< a ... @ vajhoej。 dkwrote:
On May 25, 9:37 pm, Arne Vajh?j <a...@vajhoej.dkwrote:
kevin.jenni ... @ gmail.com写道:
kevin.jenni...@gmail.com wrote:
我是编写一个C#程序来读取一个名为
LocationDetail的Access数据库表。此表由两列组成:位置,
DiscDate。它看起来像这样:
I''m writing a C# program to read from an Access database table called
LocationDetail. This table is made up of two columns: Location,
DiscDate. It looks like this:
0000001234 122590
0000001234 102207
0000001234 000000 >
1237847623 102207
1237847623 071395
4545454545 031206
4545454545 000000
等等.. 。
0000001234 122590
0000001234 102207
0000001234 000000
1237847623 102207
1237847623 071395
4545454545 031206
4545454545 000000
and so on...
第一列表示一个位置,第二列表示断开日期。
如果
日期为'000000''表示该位置处于活动状态。所以,这意味着
上面的位置0000001234是一个当前活动的位置,其中有两个
之前断开连接。
The first column denotes a location, the second a disconnect date.
If
the date is ''000000'' that means the location is active. So, that means
that location 0000001234 above is a currently active location with two
previous disconnects.
我想要做的就是通过这个表并且只能''获取'
位置没有'000000''的DiscDate。在这个例子中,
查看上面的数据,我只想要位置1237847623因为
它是唯一没有DiscDate的位置等于
''000000''。它有两个条目,两个条目都有一个有效的断开日期。
这意味着这个位置仍然是无效的。这就是我想要找到的b $ b所有非活动地点。
What I''d like to do is go through this table and only ''fetch'' the
locations that do not have a DiscDate of ''000000''. In this instance,
looking at the data above, I''d only want location 1237847623 because
it is the only location that doesn''t have a DiscDate that is equal to
''000000''. It has two entries and both have a valid disconnect date.
That means that this location is still "inactive" and that''s what I
want to find: All inactive locations.
我的C#程序当前将整个LocationDetail表加载到程序中的
数据集中。我假设我必须使用类似SQL的
命令来操作此数据集,并从中仅拉出我需要的位置
。但是,我不知道该怎么做。有人能给我看一个
的例子吗?
My C# program currently loads the entire LocationDetail table into a
dataset in the program. I''m assuming that I have to use SQL-like
commands to act on this dataset and pull only the locations I require
from it. But, I have no idea how to do that. Can someone show me an
example?
只将相关数据加载到DataSet中。
类似于:
选择位置,弃置
来自yourtable
WHERE位置不在(选择位置从yourtable WHERE
discdate =''000000'')
Arne
Only load the relevant data into the DataSet.
Something like:
SELECT location,discdate
FROM yourtable
WHERE location NOT IN (SELECT location FROM yourtable WHERE
discdate=''000000'')
Arne
感谢您的回复!我会尝试你的例子。我没有意识到
我可以在SQL中进行嵌套选择。我以前从来没有用过
除了直接''选择'以外的任何东西。
我很感激!
Kevin
Thanks for the response! I''ll try out your example. I didn''t realize
I could do nested selects in SQL. I''ve never used it before for
anything other than a straight ''select''.
I appreciate it!
Kevin
ke * ***********@gmail.com 写道:
5月25日晚9点37分,Arne Vajh?j < a ... @ vajhoej.dkwrote:
On May 25, 9:37 pm, Arne Vajh?j <a...@vajhoej.dkwrote:
> kevin.jenni ... @ gmail.com写道:
>kevin.jenni...@gmail.com wrote:
>>我正在编写一个C#程序来读取名为
LocationDetail的Access数据库表。该表由两列组成:位置,
DiscDate。它看起来像这样:
0000001234 122590
0000001234 102207
0000001234 000000
1237847623 102207
1237847623 071395
4545454545 031206
4545454545 000000
依此类推......
第一列表示一个位置,第二列表示断开日期。
如果
日期为'000000'',则表示该位置处于活动状态。所以,这意味着上面的位置0000001234是一个当前活动的位置,之前有两个断开连接。
我想要做的就是通过这个表并且只是''获取''
位置没有DiscDate为''000000''。在这个例子中,
查看上面的数据,我只想要位置1237847623,因为它是唯一一个没有DiscDate等于
''的位置000000'。它有两个条目,并且都有一个有效的断开日期。
这意味着这个位置仍然是不活动的。这就是我想要找到的:所有非活动位置。
我的C#程序当前将整个LocationDetail表加载到程序中的
数据集中。我假设我必须使用类似SQL的命令来处理这个数据集并从中拉出我需要的位置。但是,我不知道该怎么做。有人能给我看一个
的例子吗?
>>I''m writing a C# program to read from an Access database table called
LocationDetail. This table is made up of two columns: Location,
DiscDate. It looks like this:
0000001234 122590
0000001234 102207
0000001234 000000
1237847623 102207
1237847623 071395
4545454545 031206
4545454545 000000
and so on...
The first column denotes a location, the second a disconnect date.
If
the date is ''000000'' that means the location is active. So, that means
that location 0000001234 above is a currently active location with two
previous disconnects.
What I''d like to do is go through this table and only ''fetch'' the
locations that do not have a DiscDate of ''000000''. In this instance,
looking at the data above, I''d only want location 1237847623 because
it is the only location that doesn''t have a DiscDate that is equal to
''000000''. It has two entries and both have a valid disconnect date.
That means that this location is still "inactive" and that''s what I
want to find: All inactive locations.
My C# program currently loads the entire LocationDetail table into a
dataset in the program. I''m assuming that I have to use SQL-like
commands to act on this dataset and pull only the locations I require
from it. But, I have no idea how to do that. Can someone show me an
example?
只将相关数据加载到DataSet中。
类似于:
SELECT位置,discdate
来自yourtable
地点不在(从yourtable选择位置WHERE
discdate =''000000'')
Only load the relevant data into the DataSet.
Something like:
SELECT location,discdate
FROM yourtable
WHERE location NOT IN (SELECT location FROM yourtable WHERE
discdate=''000000'')
感谢您的回复!我会尝试你的例子。我没有意识到
我可以在SQL中进行嵌套选择。我以前从来没有用过
除了直接选择以外的任何东西。
Thanks for the response! I''ll try out your example. I didn''t realize
I could do nested selects in SQL. I''ve never used it before for
anything other than a straight ''select''.
几乎所有数据库除了10岁的MySQL数据库
都支持。
Arne
Practically all databases except 10 year old MySQL databases
support that.
Arne
这篇关于我可以用C#做这个吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!