数据集和数据视图存在的问题 [英] Weired Problems with Dataset and Dataviews

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

问题描述

嗨!


myDataSet从Access 2000 db填充并包含一个表


从myDataSet中的那个表创建myDataView并使用一个Rowfilter获得

a我使用的几行(我需要一个DataView,因为我做了很多

过滤)


问题是主键字段(一个独特的计数器),让我们称之为

TBL_ID。


如果我,在使用Rowfilter之后,最终得到一个具有Zero

记录的DataView,我开始在

中添加一条记录(通过数据网格)TBL_ID字段,DataView将始终启动在0 ...然后向上计数.. 1,然后2,

然后3 ..等等


但是...如果我,之后使用Rowfilter,最终得到的DataView比一条记录有更多的b
,行中的TBL_ID字段将是来自Access数据库中表格的正确数字。如果我只得到一条记录并且TBL_ID是

54 ...我创建的下一条新记录将是55等等....这就是我想要的方式

它当然是行动。


为什么myDataView在没有行时从0开始?它是由

数据集创建的,可能有很多带有ID的记录...


如何修复它?这对我来说非常头疼!


最好的问候

/ Lars Netzel

解决方案

嗨Lars,


因为数据集已断开连接。

当你使用自动增量时,你必须总是这样做


ds.update(xx)

ds.fill(xx)''用它来获取分配的数字


在此之后它需要最后分配的号码,即使另一个用户在其间添加了

之间的东西。


因此下一个添加的号码如果没有更新,你的网格不确定正确的数字

,因为另一个用户可以在表格中添加一行



我希望这能给出这个想法吗?


Cor

myDataSet从Access 2000 db填充并包含一个表

从myDataSet中的那个表我创建myDataView并使用Rowfilter
获取我使用的几行(我需要一个DataView,因为我做了很多过滤)

问题是主键字段(一个独特的计数器),让我们称之为
TBL_ID。

如果我在使用Rowfilter之后最终得到一个具有Zero
记录的DataView并开始添加记录(通过数据网格)DataView中的TBL_ID字段将始终从0开始...然后向上计数.. 1,然后是
2,然后是3 ..等等

但是......如果我在使用Rowfilter之后最终得到一个具有
多个记录的DataView,那么行中的TBL_ID字段将是来自表中的正确数字
访问数据库。如果我只得到一条记录而且TBL_ID
是54 ...我创建的下一条新记录将是55等等......这就是我想要它当然采取行动的方式。

为什么myDataView在没有行的情况下从0开始?它是从
数据集创建的,可能有很多带有ID的记录...



好的,我理解你的意思,实际上解决了另一个问题..

但不是我在这个帖子中询问的问题。


问题是如果我使用没有记录的DataView

自动增量从0开始,而Access表(基于数据视图是
)始终从1开始......这有点问题。所以当我添加一个

的新行时,我看到ID字段自动填充为0但是当我保存时,它在数据库中变为1

...然后全部应用程序中的其他信息

基于该ID(在我保存之前为0 i运行时)将全部搞砸了b
搞砸了。因为他们的ParentID是0然后就不存在了。


也许你误解了我或者你真的回答了我但是我b / b
误导了你?


我想我想要的是告诉Dataview启动

自动增量1而不是0 ....


/ Lars


" Cor Ligthert" <无********** @ planet.nl> skrev i meddelandet

新闻:%2 *************** @ tk2msftngp13.phx.gbl ...

嗨拉尔斯,

因为数据集已断开连接。
当你使用自动增量时,你必须总是这样做

ds.update(xx)
ds.fill (xx)''用它来获取分配的数字

此后它需要最后分配的数字,即使另一个用户在其间添加了
之间的东西。
<因此,网格上的下一个添加的数字在未更新时不确定正确的
数字,因为另一个用户可以在表格中添加一行。

我希望这能给出这个想法吗?

从Access 2000 db填充的myDataSet并包含一个表
从myDataSet中的那个表我创建myDataView并使用Rowfilter获取

我使用的几行(我需要一个DataView因为我做了很多
过滤ering)

问题是主要关键字段(一个独特的计数器),让我们称它为TBL_ID。

如果我,之后使用Rowfilter,最终得到一个具有Zero
记录的DataView,我开始添加一条记录(通过数据网格),DataView中的TBL_ID字段
将始终从0开始...然后向上计数.. 1,然后


2,

然后3 ..等等

但是...如果我在使用Rowfilter之后,结束使用


更多

的DataView而不是一条记录,行中的TBL_ID字段将是


=post_quotes> Access数据库中的表。如果我只得到一条记录并且
TBL_ID是

54 ...我创建的下一条新记录将是55等等....这就是我

<想要

它当然是行动的。

为什么myDataView在没有行时从0开始?它来自



数据集可能有很多带有ID的记录......




实际上,你应该从-1开始并倒计时


OHM


Lars内策尔" <无**** @ no.no>在留言中写道

新闻:uu ************** @ TK2MSFTNGP10.phx.gbl ...

好的,我明白你的意思意思是,这实际上解决了另一个问题..
但不是我在这个帖子中询问的问题。

问题是,如果我使用没有记录的DataView
自动增量从0开始,而Access表(DataView基于)始终从1开始......这有点问题。所以当我添加
a新行时,我看到ID字段自动填写0但是当我保存时,它在数据库中变为1
...然后应用程序中的所有其他信息
基于该ID(在我保存之前为0运行时)将全部搞砸了。因为他们的ParentID然后是0而且不存在。

也许你误解了我或者你真的回答了我但是我误解了你?

我猜我想要的是告诉Dataview在1而不是0开始
自动增量....

/ Lars


" Cor Ligthert <无********** @ planet.nl> skrev i meddelandet
新闻:%2 *************** @ tk2msftngp13.phx.gbl ...

嗨Lars,

因为数据集已断开连接。
当你使用自动增量时,你必须总是这样做

ds.update(xx)
ds.fill(xx)' '用它来获取分配的数字

此后它需要最后分配的数字,即使另一个用户


添加了

之间的东西介于两者之间。

因此,网格上的下一个添加的数字不确定正确的


数字

当它没有更新时,因为另一个用户可以在

表中添加一行


我希望这能给出这个想法吗?
<来自Access 2000 db并填充了一个
表的myDataSet

myDataSet
来自myDataSet中的那个表我创建e myDataView并使用Rowfilter


获取

我使用的几行(我需要一个DataView,因为我做了大量的
过滤)
如果我在使用Rowfilter之后,最后得到一个具有Zero
记录的DataView,并且我开始添加记录(通过数据网格)DataView中的TBL_ID字段将始终从0开始...然后向上计数.. 1,


然后2,

然后3 ..

但是......如果我在使用Rowfilter之后最终得到一个DataView

比一个记录有更多

,行中的TBL_ID字段将是

表中的正确数字


Access数据库。如果我只得到一条记录并且TBL_ID

54 ...我创建的下一条新记录将是55等等....这是如何



我想要

当然这样做。

为什么myDataView会从0开始没有行?它是从

创建的数据集,可能有很多带有ID的记录......





hi!

myDataSet that is fillled from an Access 2000 db and includes ONE table

From that Table in myDataSet I create myDataView and use a Rowfilter to get
a few rows that i work with (i need a DataView cause I do a lot of
filtering)

The problem is the primary key field (a unique counter), let''s call it
"TBL_ID".

If I, after using the Rowfilter, end up with a DataView that has Zero
records and I start adding a record (thru a datagrid) the TBL_ID field in
the DataView will always start on 0... and then count upwards .. 1, then 2,
then 3.. etc.

BUT... If I, after using the Rowfilter, end up with a DataView that has more
than one record, the TBL_ID field in the rows will be the right number from
the Table in the Access Database. If I get only one record and the TBL_ID is
54... the next new record I create will be 55 and etc.... This is how I want
it to act of course.

Why will myDataView start on 0 when it has no rows? It''s created from the
Dataset that might have MANY records with ids...

How do I fix it? This is a big headache for me right now!

Best Regards
/Lars Netzel

解决方案

Hi Lars,

Because the dataset is disconnected.
When you use autoincrement you would have to do always this

ds.update(xx)
ds.fill(xx) ''with this it gets the assigned numbers

After this it takes the last assigned number, even if another user has added
something between that in between.

Therefore the next added number on your grid is not sure the correct number
when it is not updated, because again another user can have added a row in
the table.

I hope this gives the idea?

Cor

myDataSet that is fillled from an Access 2000 db and includes ONE table

From that Table in myDataSet I create myDataView and use a Rowfilter to get a few rows that i work with (i need a DataView cause I do a lot of
filtering)

The problem is the primary key field (a unique counter), let''s call it
"TBL_ID".

If I, after using the Rowfilter, end up with a DataView that has Zero
records and I start adding a record (thru a datagrid) the TBL_ID field in
the DataView will always start on 0... and then count upwards .. 1, then 2, then 3.. etc.

BUT... If I, after using the Rowfilter, end up with a DataView that has more than one record, the TBL_ID field in the rows will be the right number from the Table in the Access Database. If I get only one record and the TBL_ID is 54... the next new record I create will be 55 and etc.... This is how I want it to act of course.

Why will myDataView start on 0 when it has no rows? It''s created from the
Dataset that might have MANY records with ids...



Okay I understand what you mean and that actually solved another probelm..
but not the problem I asked about in this thread.

The problem is that if I use a DataView that has no records the
Autoincrement starts on 0 whereas the Access Tables (that the DataView is
based on) always start on 1... which is a bit of a problem. So when I add a
new row I see the ID field auto fills in a 0 but When I save, it becomes 1
in the database... and then all the other information in the application
based on that ID (which is 0 i runtime before I have saved) will be all
messed up. Cause their ParentID is then 0 which does''nt exist.

Maybe you misunderstood me OR maybe you actually answered me but I
misunderstod you?

I guess What I want is someway of telling the Dataview to start the
Autoincrement on 1 and not 0....

/Lars

"Cor Ligthert" <no**********@planet.nl> skrev i meddelandet
news:%2***************@tk2msftngp13.phx.gbl...

Hi Lars,

Because the dataset is disconnected.
When you use autoincrement you would have to do always this

ds.update(xx)
ds.fill(xx) ''with this it gets the assigned numbers

After this it takes the last assigned number, even if another user has added something between that in between.

Therefore the next added number on your grid is not sure the correct number when it is not updated, because again another user can have added a row in
the table.

I hope this gives the idea?

Cor

myDataSet that is fillled from an Access 2000 db and includes ONE table

From that Table in myDataSet I create myDataView and use a Rowfilter to get

a few rows that i work with (i need a DataView cause I do a lot of
filtering)

The problem is the primary key field (a unique counter), let''s call it
"TBL_ID".

If I, after using the Rowfilter, end up with a DataView that has Zero
records and I start adding a record (thru a datagrid) the TBL_ID field in the DataView will always start on 0... and then count upwards .. 1, then


2,

then 3.. etc.

BUT... If I, after using the Rowfilter, end up with a DataView that has


more

than one record, the TBL_ID field in the rows will be the right number


from

the Table in the Access Database. If I get only one record and the TBL_ID is

54... the next new record I create will be 55 and etc.... This is how I


want

it to act of course.

Why will myDataView start on 0 when it has no rows? It''s created from


the Dataset that might have MANY records with ids...




Actually, you should start with -1 and count down

OHM

"Lars Netzel" <no****@no.no> wrote in message
news:uu**************@TK2MSFTNGP10.phx.gbl...

Okay I understand what you mean and that actually solved another probelm..
but not the problem I asked about in this thread.

The problem is that if I use a DataView that has no records the
Autoincrement starts on 0 whereas the Access Tables (that the DataView is
based on) always start on 1... which is a bit of a problem. So when I add a new row I see the ID field auto fills in a 0 but When I save, it becomes 1
in the database... and then all the other information in the application
based on that ID (which is 0 i runtime before I have saved) will be all
messed up. Cause their ParentID is then 0 which does''nt exist.

Maybe you misunderstood me OR maybe you actually answered me but I
misunderstod you?

I guess What I want is someway of telling the Dataview to start the
Autoincrement on 1 and not 0....

/Lars

"Cor Ligthert" <no**********@planet.nl> skrev i meddelandet
news:%2***************@tk2msftngp13.phx.gbl...

Hi Lars,

Because the dataset is disconnected.
When you use autoincrement you would have to do always this

ds.update(xx)
ds.fill(xx) ''with this it gets the assigned numbers

After this it takes the last assigned number, even if another user has


added

something between that in between.

Therefore the next added number on your grid is not sure the correct


number

when it is not updated, because again another user can have added a row in

the table.

I hope this gives the idea?

Cor

myDataSet that is fillled from an Access 2000 db and includes ONE table
From that Table in myDataSet I create myDataView and use a Rowfilter

to get

a few rows that i work with (i need a DataView cause I do a lot of
filtering)

The problem is the primary key field (a unique counter), let''s call it
"TBL_ID".

If I, after using the Rowfilter, end up with a DataView that has Zero
records and I start adding a record (thru a datagrid) the TBL_ID field in the DataView will always start on 0... and then count upwards .. 1,

then 2,

then 3.. etc.

BUT... If I, after using the Rowfilter, end up with a DataView that

has more

than one record, the TBL_ID field in the rows will be the right number


from

the Table in the Access Database. If I get only one record and the TBL_ID

is

54... the next new record I create will be 55 and etc.... This is how


I want

it to act of course.

Why will myDataView start on 0 when it has no rows? It''s created from


the Dataset that might have MANY records with ids...





这篇关于数据集和数据视图存在的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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