丢弃数据集中的行。 [英] Discarding rows in dataset.

查看:61
本文介绍了丢弃数据集中的行。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


有人能够告诉我从数据集中删除

不需要的行的最优雅方式更新前的情况?或者,

在将行初始添加到

记录集后将所有行重置为未更改。


我创建了一个数据集,在初始.Fill之后开始为空。


然后我用一些默认信息创建几行,留下一个

关键信息值为0;


dr = ds.Tables(" mytable")。NewRow()

带博士

.Item(" basicdata1" ;)= myvalue1

.Item(" basicdata2")= myvalue2

.Item(" criticaldata")= 0

。项目(" created")=现在()

结束

ds.Tables(" mytable")。Rows.Add(dr)


然后,我的更新做了类似的事情;


da.Update(ds," mytable")


全部非常基本的东西......但我想要的是只将新行

插入到具有criticaldata的数据库中。值<> 0并弃掉

休息。我可以使用GetChanges方法,如果我知道如何在创建后立即将行标记为

''不变' - 但不知道如何。


任何帮助将不胜感激。

谢谢,


格雷厄姆

Hi all,

Would someone be able to tell me the most ''graceful'' way of removing
unwanted rows from a dataset based on a condition prior to update? OR,
resetting the rows all to unchanged after they are initally added to the
recordset.

I create a dataset, which begins empty after the initial .Fill.

Then I create several rows with some default information, leaving one
critical piece of information value as 0;

dr = ds.Tables("mytable").NewRow()
With dr
.Item("basicdata1") = myvalue1
.Item("basicdata2") = myvalue2
.Item("criticaldata") = 0
.Item("created") = Now()
End With
ds.Tables("mytable").Rows.Add(dr)

Then, my update does something like;

da.Update(ds, "mytable")

All pretty basic stuff.... but what I would like is to ONLY insert new rows
into the database that have a "criticaldata" value <> 0 and discard the
rest. I could use the GetChanges method if I knew how to mark the rows as
''unchanged'' immediately after creation - but don''t know how.

Any help would be greatly appreciated.
Thanks,

Graham

推荐答案

你可以使用GetChanges获取RowState或添加的行。然后

在GetChanges表上调用更新 - 然后在原始上接受更改

-

WG Ryan MVP Windows - Embedded


对微软嵌入式新闻组的有效性有意见吗?

让微软知道!
https://www.windowsembeddedeval.com/...ity/newsgroups

" Graham Blandford" < GR ************** @ sympatico.ca>在消息中写道

news:tH ********************* @ news20.bellglobal.com ...
YOu can use GetChanges and just get the rows with RowState or added. Then
call update on the GetChanges table - then acceptChanges on the original
--
W.G. Ryan MVP Windows - Embedded

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/...ity/newsgroups
"Graham Blandford" <gr**************@sympatico.ca> wrote in message
news:tH*********************@news20.bellglobal.com ...

根据更新前的情况,有人能告诉我从数据集中删除不需要的行的最优雅方式吗?或者,
在将行初始添加到
记录集后将所有行重置为未更改。

我创建了一个数据集,在初始.Fill之后开始为空。

然后我用一些默认信息创建几行,将一个
关键信息值保留为0;

dr = ds.Tables(" mytable")。NewRow ()
随着
.Item(" basicdata1")= myvalue1
.Item(" basicdata2")= myvalue2
.Item(" criticaldata")= 0
.Item(" created")= Now()
结束
ds.Tables(" mytable")。Rows.Add(dr)

然后,我的更新做了类似的事情;

da.Update(ds,mytable)

所有非常基本的东西....但我想要的是只需将新的
行插入到具有criticaldata的数据库中。值<> 0并丢弃
休息。我可以使用GetChanges方法,如果我知道如何在创建后立即将行标记为未更改 - 但不知道如何。

任何帮助将不胜感激。
谢谢,

格雷厄姆
Hi all,

Would someone be able to tell me the most ''graceful'' way of removing
unwanted rows from a dataset based on a condition prior to update? OR,
resetting the rows all to unchanged after they are initally added to the
recordset.

I create a dataset, which begins empty after the initial .Fill.

Then I create several rows with some default information, leaving one
critical piece of information value as 0;

dr = ds.Tables("mytable").NewRow()
With dr
.Item("basicdata1") = myvalue1
.Item("basicdata2") = myvalue2
.Item("criticaldata") = 0
.Item("created") = Now()
End With
ds.Tables("mytable").Rows.Add(dr)

Then, my update does something like;

da.Update(ds, "mytable")

All pretty basic stuff.... but what I would like is to ONLY insert new rows into the database that have a "criticaldata" value <> 0 and discard the
rest. I could use the GetChanges method if I knew how to mark the rows as
''unchanged'' immediately after creation - but don''t know how.

Any help would be greatly appreciated.
Thanks,

Graham



我猜row.AcceptChanges会做。


" Graham Blandford" < GR ************** @ sympatico.ca>在消息中写道

news:tH ********************* @ news20.bellglobal.com ...
I guess row.AcceptChanges will do.

"Graham Blandford" <gr**************@sympatico.ca> wrote in message
news:tH*********************@news20.bellglobal.com ...

根据更新前的情况,有人能告诉我从数据集中删除不需要的行的最优雅方式吗?或者,
在将行初始添加到
记录集后将所有行重置为未更改。

我创建了一个数据集,在初始.Fill之后开始为空。

然后我用一些默认信息创建几行,将一个
关键信息值保留为0;

dr = ds.Tables(" mytable")。NewRow ()
随着
.Item(" basicdata1")= myvalue1
.Item(" basicdata2")= myvalue2
.Item(" criticaldata")= 0
.Item(" created")= Now()
结束
ds.Tables(" mytable")。Rows.Add(dr)

然后,我的更新做了类似的事情;

da.Update(ds,mytable)

所有非常基本的东西....但我想要的是只需将新的
行插入到具有criticaldata的数据库中。值<> 0并丢弃
休息。我可以使用GetChanges方法,如果我知道如何在创建后立即将行标记为未更改 - 但不知道如何。

任何帮助将不胜感激。
谢谢,

格雷厄姆
Hi all,

Would someone be able to tell me the most ''graceful'' way of removing
unwanted rows from a dataset based on a condition prior to update? OR,
resetting the rows all to unchanged after they are initally added to the
recordset.

I create a dataset, which begins empty after the initial .Fill.

Then I create several rows with some default information, leaving one
critical piece of information value as 0;

dr = ds.Tables("mytable").NewRow()
With dr
.Item("basicdata1") = myvalue1
.Item("basicdata2") = myvalue2
.Item("criticaldata") = 0
.Item("created") = Now()
End With
ds.Tables("mytable").Rows.Add(dr)

Then, my update does something like;

da.Update(ds, "mytable")

All pretty basic stuff.... but what I would like is to ONLY insert new rows into the database that have a "criticaldata" value <> 0 and discard the
rest. I could use the GetChanges method if I knew how to mark the rows as
''unchanged'' immediately after creation - but don''t know how.

Any help would be greatly appreciated.
Thanks,

Graham



Graham,

In除了使用DataRowState的GetChanges,你可以使用

DataTable.Select。


我会推荐DataTable.Select,因为你返回了对
的引用现有DataSet中的
行,其中GetChanges将返回一个新的DataSet

(带有新行)。


David Sceppa解释了它们之间的区别GetChanges&当你打算在他的书Microsoft ADO.NET - Core

Reference中更新数据库时,选择你想要更新数据库。来自MS

按。


如果你在ADO.NET上做了很多我强烈推荐Sceppa的书,

这是一个关于ADO.NET的好教程以及一个很好的桌面参考一次

你知道ADO.NET。


希望这有助于

Jay

" Graham Blandford" < GR ************** @ sympatico.ca>在消息中写道

news:tH ********************* @ news20.bellglobal.com ...
Graham,
In addition to GetChanges with the DataRowState you can use
DataTable.Select.

I would recommend DataTable.Select as you are returned references to the
rows in the existing DataSet, where as GetChanges will return a new DataSet
(with new rows).

David Sceppa explains the difference between GetChanges & Select when you
intend on updating the database in his book "Microsoft ADO.NET - Core
Reference" from MS
Press.

If you are doing a lot with ADO.NET I strongly recommend Sceppa''s book,
which is a good tutorial on ADO.NET as well as a good desk reference once
you know ADO.NET.

Hope this helps
Jay
"Graham Blandford" <gr**************@sympatico.ca> wrote in message
news:tH*********************@news20.bellglobal.com ...

根据更新前的情况,有人能告诉我从数据集中删除不需要的行的最优雅方式吗?或者,
在将行初始添加到
记录集后将所有行重置为未更改。

我创建了一个数据集,在初始.Fill之后开始为空。

然后我用一些默认信息创建几行,将一个
关键信息值保留为0;

dr = ds.Tables(" mytable")。NewRow ()
随着
.Item(" basicdata1")= myvalue1
.Item(" basicdata2")= myvalue2
.Item(" criticaldata")= 0
.Item(" created")= Now()
结束
ds.Tables(" mytable")。Rows.Add(dr)

然后,我的更新做了类似的事情;

da.Update(ds,mytable)

所有非常基本的东西....但我想要的是只需将新的
行插入到具有criticaldata的数据库中。值<> 0并丢弃
休息。我可以使用GetChanges方法,如果我知道如何在创建后立即将行标记为未更改 - 但不知道如何。

任何帮助将不胜感激。
谢谢,

格雷厄姆
Hi all,

Would someone be able to tell me the most ''graceful'' way of removing
unwanted rows from a dataset based on a condition prior to update? OR,
resetting the rows all to unchanged after they are initally added to the
recordset.

I create a dataset, which begins empty after the initial .Fill.

Then I create several rows with some default information, leaving one
critical piece of information value as 0;

dr = ds.Tables("mytable").NewRow()
With dr
.Item("basicdata1") = myvalue1
.Item("basicdata2") = myvalue2
.Item("criticaldata") = 0
.Item("created") = Now()
End With
ds.Tables("mytable").Rows.Add(dr)

Then, my update does something like;

da.Update(ds, "mytable")

All pretty basic stuff.... but what I would like is to ONLY insert new rows into the database that have a "criticaldata" value <> 0 and discard the
rest. I could use the GetChanges method if I knew how to mark the rows as
''unchanged'' immediately after creation - but don''t know how.

Any help would be greatly appreciated.
Thanks,

Graham



这篇关于丢弃数据集中的行。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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