473,405 Members | 2,262 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Weired Problems with Dataset and Dataviews

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

Nov 20 '05 #1
13 1805
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...

Nov 20 '05 #2
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...


Nov 20 '05 #3
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...



Nov 20 '05 #4
Actually... If I use the DataTable as DataSource in the grid instead of the
DataView, the Autoincrement starts on 0 anyway... So it's not only the
DataView tha tis a problem for me..

Why does it start on 0 when Access 2000 starts on 1?

/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...


Nov 20 '05 #5
What?

An Autoincrement cant' start on -1 and even if it could, it does'nt... it
starts on 0 in the DataView and the DataTable... and I want it to start on
1, since it's impossible to have a record in Access 2000 with an ID of 0 (if
it is an Autoincrement field)

/Lars
"One Handed Man ( OHM#)" <news.microsoft.com> skrev i meddelandet
news:uH**************@tk2msftngp13.phx.gbl...
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...



Nov 20 '05 #6
Wrong !

You misunderstand me.

The DataColumn class has an AutoIncrement Step which can be -1 and a See
which can be -1, therefore it is possible to allow the table to
Autoincrement in a negative direction. When Rows are insterted in the source
database, they can then take on new numbers, having the primary key set to a
negative index ensures that they never clash with existing numbers.

OHM
"Lars Netzel" <no****@no.no> wrote in message
news:u%****************@TK2MSFTNGP09.phx.gbl...
What?

An Autoincrement cant' start on -1 and even if it could, it does'nt... it
starts on 0 in the DataView and the DataTable... and I want it to start on
1, since it's impossible to have a record in Access 2000 with an ID of 0 (if it is an Autoincrement field)

/Lars
"One Handed Man ( OHM#)" <news.microsoft.com> skrev i meddelandet
news:uH**************@tk2msftngp13.phx.gbl...
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...
>
>



Nov 20 '05 #7
Okay, I have found where to set the Seed now.. but where in access can I
choose to use Negative Autoincrement?

/Lars

"One Handed Man ( OHM#)" <news.microsoft.com> skrev i meddelandet
news:e8*************@tk2msftngp13.phx.gbl...
Wrong !

You misunderstand me.

The DataColumn class has an AutoIncrement Step which can be -1 and a See
which can be -1, therefore it is possible to allow the table to
Autoincrement in a negative direction. When Rows are insterted in the source database, they can then take on new numbers, having the primary key set to a negative index ensures that they never clash with existing numbers.

OHM
"Lars Netzel" <no****@no.no> wrote in message
news:u%****************@TK2MSFTNGP09.phx.gbl...
What?

An Autoincrement cant' start on -1 and even if it could, it does'nt... it
starts on 0 in the DataView and the DataTable... and I want it to start on 1, since it's impossible to have a record in Access 2000 with an ID of 0

(if
it is an Autoincrement field)

/Lars
"One Handed Man ( OHM#)" <news.microsoft.com> skrev i meddelandet
news:uH**************@tk2msftngp13.phx.gbl...
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...
> >
> >
>
>



Nov 20 '05 #8
Hi Lars,

I have tried what you said, and it looks weird with the allownew = true.
I would not use that in this situation from you.

There is some behaviour that the fill after the update updates the dataset,
however does not things as deleting old rows that is probably as well
affected here. (I do not understand why however it seems to be)

That is not nice, therefore with those autoincrements, I think that you can
better do something as, (you would have to do that as well when you have
deletes in your dataset).
da.Update(ds)
ds.Clear()
da.Fill(ds)

I think the next is useless in this situation, however that is up to you,
setting the seed to 1 is:
ds.Tables(0).Columns("YourAutoIncKey").AutoIncreme ntSeed = 1

I hope this helps?

Cor
Nov 20 '05 #9
Lars,

Just make sure your ID is an Autonumber field in Access and all you have to
do Update, the dataAdapter will take care of it for you. You will find that
your new records have new sequential positive numbers in the Access DB.

Regards - OHM
"Lars Netzel" <no****@no.no> wrote in message
news:u8****************@TK2MSFTNGP11.phx.gbl...
Okay, I have found where to set the Seed now.. but where in access can I
choose to use Negative Autoincrement?

/Lars

"One Handed Man ( OHM#)" <news.microsoft.com> skrev i meddelandet
news:e8*************@tk2msftngp13.phx.gbl...
Wrong !

You misunderstand me.

The DataColumn class has an AutoIncrement Step which can be -1 and a See
which can be -1, therefore it is possible to allow the table to
Autoincrement in a negative direction. When Rows are insterted in the source
database, they can then take on new numbers, having the primary key set to a
negative index ensures that they never clash with existing numbers.

OHM
"Lars Netzel" <no****@no.no> wrote in message
news:u%****************@TK2MSFTNGP09.phx.gbl...
What?

An Autoincrement cant' start on -1 and even if it could, it does'nt... it starts on 0 in the DataView and the DataTable... and I want it to start
on
1, since it's impossible to have a record in Access 2000 with an ID of
0 (if
it is an Autoincrement field)

/Lars
"One Handed Man ( OHM#)" <news.microsoft.com> skrev i meddelandet
news:uH**************@tk2msftngp13.phx.gbl...
> 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...
> > >
> > >
> >
> >
>
>



Nov 20 '05 #10
What do you mean with that the AllowNew might mess things up?

/Lars
"Cor Ligthert" <no**********@planet.nl> skrev i meddelandet
news:eJ**************@TK2MSFTNGP12.phx.gbl...
Hi Lars,

I have tried what you said, and it looks weird with the allownew = true.
I would not use that in this situation from you.

There is some behaviour that the fill after the update updates the dataset, however does not things as deleting old rows that is probably as well
affected here. (I do not understand why however it seems to be)

That is not nice, therefore with those autoincrements, I think that you can better do something as, (you would have to do that as well when you have
deletes in your dataset).
da.Update(ds)
ds.Clear()
da.Fill(ds)

I think the next is useless in this situation, however that is up to you,
setting the seed to 1 is:
ds.Tables(0).Columns("YourAutoIncKey").AutoIncreme ntSeed = 1

I hope this helps?

Cor

Nov 20 '05 #11
Lars,

In the dataview you can set
dv.allownew = false

Then that automatic * row in the datagrid will not appear, when you add a
button to your form for a row and add with that to the datatable, then the
new row appears.

In your situation a row is created, which probably should not be there,
however than you cannot add rows, because that standard addrow * is not on
the datagrid.

Just my opinion however.

Cor
Nov 20 '05 #12
Lars,
In addition to the other's comments:

See the DataColumn.AutoIncrement, DataColumn.AutoIncrementSeed, and
DataColumn.AutoIncrementStep properties.

It is recommended that you make AutoIncrementStep & AutoIncrementSeed
both -1 on AutoIncrement columns so as to avoid conflicts between
autoincrement values assign by your Database (Access or SQL Server) and your
DataSet.

However you then need to have your update query return the newly assigned
AutoIncrement value when you update your database.

For a good tutorial on ADO.NET as well as a good desk reference once you
know ADO.NET see David Sceppa's book "Microsoft ADO.NET - Core Reference"
from MS press. David also shows how to use the -1 AutoIncrement in the
DataSet and have the database update the dataset (during DataSet.Update).

Hope this helps
Jay
"Lars Netzel" <no****@no.no> wrote in message
news:u8****************@TK2MSFTNGP11.phx.gbl...
Okay, I have found where to set the Seed now.. but where in access can I
choose to use Negative Autoincrement?

/Lars

"One Handed Man ( OHM#)" <news.microsoft.com> skrev i meddelandet
news:e8*************@tk2msftngp13.phx.gbl...
Wrong !

You misunderstand me.

The DataColumn class has an AutoIncrement Step which can be -1 and a See
which can be -1, therefore it is possible to allow the table to
Autoincrement in a negative direction. When Rows are insterted in the source
database, they can then take on new numbers, having the primary key set to a
negative index ensures that they never clash with existing numbers.

OHM
"Lars Netzel" <no****@no.no> wrote in message
news:u%****************@TK2MSFTNGP09.phx.gbl...
What?

An Autoincrement cant' start on -1 and even if it could, it does'nt... it starts on 0 in the DataView and the DataTable... and I want it to start
on
1, since it's impossible to have a record in Access 2000 with an ID of
0 (if
it is an Autoincrement field)

/Lars
"One Handed Man ( OHM#)" <news.microsoft.com> skrev i meddelandet
news:uH**************@tk2msftngp13.phx.gbl...
> 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...
> > >
> > >
> >
> >
>
>



Nov 20 '05 #13
see new thread "a VERY weird probelm when updating dataset" about my
problems after doing this and using Negative IDs

/lars

"Cor Ligthert" <no**********@planet.nl> skrev i meddelandet
news:eT**************@TK2MSFTNGP09.phx.gbl...
Lars,

In the dataview you can set
dv.allownew = false

Then that automatic * row in the datagrid will not appear, when you add a
button to your form for a row and add with that to the datatable, then the
new row appears.

In your situation a row is created, which probably should not be there,
however than you cannot add rows, because that standard addrow * is not on
the datagrid.

Just my opinion however.

Cor

Nov 20 '05 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Lester Moreno | last post by:
Hello all, Up to now C# have been an great experience but I found myself in a end of the road problem. Let say that you have two windows program running on a local network area. User1 and...
1
by: david | last post by:
i am tring to generate a single dataset which contains all records from a table and then create subsets of this dataset which can fill certail controls and i am not sure of the best method eg....
1
by: Arpan | last post by:
The following ASPX code snippet creates a DataSet programmatically right from the scratch: 'create an empty DataSet Dim objDS As New DataSet("MyDataSet") 'create a new table & add columns Dim...
0
by: M. David Johnson | last post by:
I cannot get my OleDbDataAdapter to update my database table from my local dataset table. The Knowledge Base doesn't seem to help - see item 10 below. I have a Microsoft Access 2000 database...
2
by: Jeff Brown | last post by:
OK i have came to the conclusion that since this app will be run on multiple computers that loading a complete database and then updating on exit is a moot point. I have tried several ideas...
2
by: John Granade | last post by:
I'm looking for the best way to make a dataset available from multiple Windows forms. The dataset is created from an XML file. I have a main form (frmMain) that loads the dataset and reads the...
2
by: Carl Summers | last post by:
I have a table in an Access database that has no sort applied in Access. When I fill a dataset with data from that table (the entire one dimensional table) my dataset is sorted differently than...
17
by: A_PK | last post by:
I have problem databinding the DataGrid with DataView/DataSet after the filter... I create the following proceudre in order for user to filter as many as they want, but the following code is only...
3
by: lgbjr | last post by:
Hi All, I need some help getting data from an XML file into a dataset. The XML file has more data in it than I actually need. So, what I think I need to do is to create a dataset with the tables...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.