473,399 Members | 2,146 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,399 software developers and data experts.

Truly frustrated

Hi all,

I don't know how many hours I've spend on this but I don't want to give up
and there has to be a way of doing this. Here is what I'm trying to do:

I have a small Windows Forms app where I create a DataSet to hold temp info.
I do not need to display the data to the user but I need to manipulate the
data with code. There is just one table in the set with 8 columns. One of
the columns is configured as a PK. In the code I step through the rows and
test for conditions. Once I have found a row that meets the condition I need
to update one column of the row with new data.

The books (I have several that I bought out of desperation looking for
answers) say that if you have a unique key (PK is def. unique) and you use
the dt.rows.add with an existing value for the PK, it will replace data
rather than creating a new row. When I tried that an exception was thrown. I
then used the dt.BeginLoadData. That didn't work either. It still created a
new row and when I issued the dt.EndLoadData I got an exception that there
are 2 rows with the same value.

Can anybody tell me how I can change the value of one column through code
without binding den DataSet to a list or DataGrid? There has to be a way of
doing this.

Thanks
Claus
Nov 21 '05 #1
9 963
I did find it. For anybody that runs into the same issue it's soooooooo
simple once you figure it out but it is not documented anywhere. The key is
ds.AcceptChanges.
I created an incident of the row, replace the one value and then issued a
ds.AcceptChanges.
"cjobes" <cj****@nova-tech.org> wrote in message
news:OE**************@TK2MSFTNGP12.phx.gbl...
Hi all,

I don't know how many hours I've spend on this but I don't want to give up
and there has to be a way of doing this. Here is what I'm trying to do:

I have a small Windows Forms app where I create a DataSet to hold temp info. I do not need to display the data to the user but I need to manipulate the
data with code. There is just one table in the set with 8 columns. One of
the columns is configured as a PK. In the code I step through the rows and
test for conditions. Once I have found a row that meets the condition I need to update one column of the row with new data.

The books (I have several that I bought out of desperation looking for
answers) say that if you have a unique key (PK is def. unique) and you use
the dt.rows.add with an existing value for the PK, it will replace data
rather than creating a new row. When I tried that an exception was thrown. I then used the dt.BeginLoadData. That didn't work either. It still created a new row and when I issued the dt.EndLoadData I got an exception that there
are 2 rows with the same value.

Can anybody tell me how I can change the value of one column through code
without binding den DataSet to a list or DataGrid? There has to be a way of doing this.

Thanks
Claus

Nov 21 '05 #2
Cjobes,

It can be the solution, know however that "acceptchanges" set all datarows
too "unchanged" and therefore makes it impossible to update those too a
database after that.

Maybe this helps?

Cor

"cjobes" <cj****@nova-tech.org>
I did find it. For anybody that runs into the same issue it's soooooooo
simple once you figure it out but it is not documented anywhere. The key
is
ds.AcceptChanges.
I created an incident of the row, replace the one value and then issued a
ds.AcceptChanges.
"cjobes" <cj****@nova-tech.org> wrote in message
news:OE**************@TK2MSFTNGP12.phx.gbl...
Hi all,

I don't know how many hours I've spend on this but I don't want to give
up
and there has to be a way of doing this. Here is what I'm trying to do:

I have a small Windows Forms app where I create a DataSet to hold temp

info.
I do not need to display the data to the user but I need to manipulate
the
data with code. There is just one table in the set with 8 columns. One of
the columns is configured as a PK. In the code I step through the rows
and
test for conditions. Once I have found a row that meets the condition I

need
to update one column of the row with new data.

The books (I have several that I bought out of desperation looking for
answers) say that if you have a unique key (PK is def. unique) and you
use
the dt.rows.add with an existing value for the PK, it will replace data
rather than creating a new row. When I tried that an exception was
thrown.

I
then used the dt.BeginLoadData. That didn't work either. It still created

a
new row and when I issued the dt.EndLoadData I got an exception that
there
are 2 rows with the same value.

Can anybody tell me how I can change the value of one column through code
without binding den DataSet to a list or DataGrid? There has to be a way

of
doing this.

Thanks
Claus


Nov 21 '05 #3
Thanks Cor,

In this case there is no database. What I use this for is to read a
delimeted txt file, manipulate the text and write it back to another file.
But for future reference, what other option would I have?

Claus

"Cor Ligthert" <no************@planet.nl> wrote in message
news:ep*************@TK2MSFTNGP11.phx.gbl...
Cjobes,

It can be the solution, know however that "acceptchanges" set all datarows
too "unchanged" and therefore makes it impossible to update those too a
database after that.

Maybe this helps?

Cor

"cjobes" <cj****@nova-tech.org>
I did find it. For anybody that runs into the same issue it's soooooooo
simple once you figure it out but it is not documented anywhere. The key
is
ds.AcceptChanges.
I created an incident of the row, replace the one value and then issued a ds.AcceptChanges.
"cjobes" <cj****@nova-tech.org> wrote in message
news:OE**************@TK2MSFTNGP12.phx.gbl...
Hi all,

I don't know how many hours I've spend on this but I don't want to give
up
and there has to be a way of doing this. Here is what I'm trying to do:

I have a small Windows Forms app where I create a DataSet to hold temp

info.
I do not need to display the data to the user but I need to manipulate
the
data with code. There is just one table in the set with 8 columns. One of the columns is configured as a PK. In the code I step through the rows
and
test for conditions. Once I have found a row that meets the condition I

need
to update one column of the row with new data.

The books (I have several that I bought out of desperation looking for
answers) say that if you have a unique key (PK is def. unique) and you
use
the dt.rows.add with an existing value for the PK, it will replace data
rather than creating a new row. When I tried that an exception was
thrown.

I
then used the dt.BeginLoadData. That didn't work either. It still created
a
new row and when I issued the dt.EndLoadData I got an exception that
there
are 2 rows with the same value.

Can anybody tell me how I can change the value of one column through
code without binding den DataSet to a list or DataGrid? There has to be a

way of
doing this.

Thanks
Claus



Nov 21 '05 #4
Cjobes

The books (I have several that I bought out of desperation looking for
answers) say that if you have a unique key (PK is def. unique) and you use
the dt.rows.add with an existing value for the PK, it will replace data
rather than creating a new row.

Weird book, I never have noticed that.

And should have been written here when it was like that in my opinion.
http://msdn.microsoft.com/library/de...ssAddTopic.asp

And it is n my opinion absolute not logical.

A datarow is an object that holds only references to items which are objects
again. Would be a kind of those strange methods we saw in past in VB6, which
some people like, however not me.

For me it is in that standalone dataset just testing on existing key, as
that not exist create a new row with a new key and than replace the values
in that newrow or that existing row. (not in the key).

When it is about a form you can look by the way as well to the databinding,
than you can use the currencymanager.addnew.

I hope this helps?

Cor
">
In this case there is no database. What I use this for is to read a
delimeted txt file, manipulate the text and write it back to another file.
But for future reference, what other option would I have?

Claus

Nov 21 '05 #5
doh,
The books (I have several that I bought out of desperation looking for
answers) say that if you have a unique key (PK is def. unique) and you
use
the dt.rows.add with an existing value for the PK, it will replace data
rather than creating a new row.

That part is not from me, before somebody misunderstand this.

Cor
Nov 21 '05 #6
Cjobes

The books (I have several that I bought out of desperation looking for
answers) say that if you have a unique key (PK is def. unique) and you use
the dt.rows.add with an existing value for the PK, it will replace data
rather than creating a new row.

Weird book, I never have noticed that.

And should have been written here when it was like that in my opinion.
http://msdn.microsoft.com/library/de...ssAddTopic.asp

And it is n my opinion absolute not logical.

A datarow is an object that holds only references to items which are objects
again. Would be a kind of those strange methods we saw in past in VB6, which
some people like, however not me.

For me it is in that standalone dataset just testing on existing key, as
that not exist create a new row with a new key and than replace the values
in that newrow or that existing row. (not in the key).

When it is about a form you can look by the way as well to the databinding,
than you can use the currencymanager.addnew.

I hope this helps?

Cor
">
In this case there is no database. What I use this for is to read a
delimeted txt file, manipulate the text and write it back to another file.
But for future reference, what other option would I have?

Claus

Nov 21 '05 #7
doh,
The books (I have several that I bought out of desperation looking for
answers) say that if you have a unique key (PK is def. unique) and you
use
the dt.rows.add with an existing value for the PK, it will replace data
rather than creating a new row.

That part is not from me, before somebody misunderstand this.

Cor
Nov 21 '05 #8
Cor

Thanks for your help. Here is the book:
Francesco Balena "Programming Microsoft Visual Basic.Net Page 1064 (mid
page).

Claus

"Cor Ligthert" <no************@planet.nl> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
Cjobes

The books (I have several that I bought out of desperation looking for
answers) say that if you have a unique key (PK is def. unique) and you use
the dt.rows.add with an existing value for the PK, it will replace data
rather than creating a new row.

Weird book, I never have noticed that.

And should have been written here when it was like that in my opinion.
http://msdn.microsoft.com/library/de...ssAddTopic.asp
And it is n my opinion absolute not logical.

A datarow is an object that holds only references to items which are objects again. Would be a kind of those strange methods we saw in past in VB6, which some people like, however not me.

For me it is in that standalone dataset just testing on existing key, as
that not exist create a new row with a new key and than replace the values in that newrow or that existing row. (not in the key).

When it is about a form you can look by the way as well to the databinding, than you can use the currencymanager.addnew.

I hope this helps?

Cor
">
In this case there is no database. What I use this for is to read a
delimeted txt file, manipulate the text and write it back to another file. But for future reference, what other option would I have?

Claus


Nov 21 '05 #9
Cor

Thanks for your help. Here is the book:
Francesco Balena "Programming Microsoft Visual Basic.Net Page 1064 (mid
page).

Claus

"Cor Ligthert" <no************@planet.nl> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
Cjobes

The books (I have several that I bought out of desperation looking for
answers) say that if you have a unique key (PK is def. unique) and you use
the dt.rows.add with an existing value for the PK, it will replace data
rather than creating a new row.

Weird book, I never have noticed that.

And should have been written here when it was like that in my opinion.
http://msdn.microsoft.com/library/de...ssAddTopic.asp
And it is n my opinion absolute not logical.

A datarow is an object that holds only references to items which are objects again. Would be a kind of those strange methods we saw in past in VB6, which some people like, however not me.

For me it is in that standalone dataset just testing on existing key, as
that not exist create a new row with a new key and than replace the values in that newrow or that existing row. (not in the key).

When it is about a form you can look by the way as well to the databinding, than you can use the currencymanager.addnew.

I hope this helps?

Cor
">
In this case there is no database. What I use this for is to read a
delimeted txt file, manipulate the text and write it back to another file. But for future reference, what other option would I have?

Claus


Nov 21 '05 #10

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

Similar topics

43
by: steve | last post by:
I am quite frustrated with php’s include, as I have spent a ton of time on it already... anyone can tell me why it was designed like this (or something I don’t get)? The path in include is...
23
by: Alvin | last post by:
Well, I'm developing a Tetris game in SDL, but when it comes to deciding the next block, I'm stuck. It's random, but when I try something like seeding the randomizer with the time, it won't update...
114
by: Andy | last post by:
Dear Python dev community, I'm CTO at a small software company that makes music visualization software (you can check us out at www.soundspectrum.com). About two years ago we went with decision...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.