|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
urgent! dataset updation in wrong rowive been using a certain code for updating information from a windows form to an Access database , and it was handling the addition of new information properly until now. now suddenly the dataset seems to be reordering the rows in an arbitrary fashion, and since i use ds.tables("form1").rows(ctr-1).item(*column name*) to add the data, the information keeps getting added to the wrong row. moreover, the program picks one row and keeps overwriting the information ONLY to that one row no matter how many new rows i create, which makes it weirder still because the variable ctr is defined as ctr = ds.tables("form1").rows.count i dont have any constraints on my sql select statement when i access the database - no order by or sort by.ive also checked my code several times to see if ive reassigned the ctr value anywhere but i havent, so thats not the problem. can someone please help? thanks in advance. -- Message posted via DotNetMonster.com http://www.dotnetmonster.com/Uwe/Forums.aspx/dotnet-vb-net/200606/1 how tragic, nobody knows?! :(
-- Message posted via DotNetMonster.com http://www.dotnetmonster.com/Uwe/Forums.aspx/dotnet-vb-net/200606/1 hi! thanks very much for responding.
after breaking my head over it the whole weekend, the problem is fixed. just in case someone else is struggling with the same thing, here's what i did: the data adapter wasnt (for some unfathomable reason) able to find the updated version of the row it correctly updated a few moments earlier. the trick is to juggle with the linking to the database and allowing the dataset to reload. i just closed connection and reopened - and that fixed the concurrency issue. i still dont know why the dataset loads haphazardedly, and picks only one "favourite" row. so i fixed a datetime on the first upload of information, saved it and searched for that particular datetime to find the correct row again for the second update. so there. it doesnt explain why it all (mal)functions like that, but hey, at least the desired result's achieved huh :) cheers! -- Message posted via DotNetMonster.com http://www.dotnetmonster.com/Uwe/Forums.aspx/dotnet-vb-net/200606/1 m.ra,
Sounds like a primary key was added to the DataTable, and you are modifying one of the key fields. However I have not tested this to confirm it. Can you post a small but complete program that demonstrates the problem? http://www.yoda.arachsys.com/csharp/complete.html One possible way to avoid the problem: Rather then use the rows indexer to get to the row: | ds.tables("form1").rows(ctr-1).item(*column name*) I would put the row in a variable, then modify the row from there.Dim row As DataRow row = ds.tables("form1").rows(ctr-1) row.item("column1") = 1 row.item("column2") = 2 -- Hope this helps Jay B. Harlow [MVP - Outlook] ..NET Application Architect, Enthusiast, & Evangelist T.S. Bradley - http://www.tsbradley.net "m.ra. via DotNetMonster.com" <u16975@uwe> wrote in message news:61d8785f00d9a@uwe...Show quoteHide quote | hi. | | ive been using a certain code for updating information from a windows form | to an Access database , and it was handling the addition of new information | properly until now. | | now suddenly the dataset seems to be reordering the rows in an arbitrary | fashion, and since i use | | ds.tables("form1").rows(ctr-1).item(*column name*) | | to add the data, the information keeps getting added to the wrong row. | moreover, the program picks one row and keeps overwriting the information | ONLY to that one row no matter how many new rows i create, which makes it | weirder still because the variable ctr is defined as | | ctr = ds.tables("form1").rows.count | | i dont have any constraints on my sql select statement when i access the | database - no order by or sort by.ive also checked my code several times to | see if ive reassigned the ctr value anywhere but i havent, so thats not the | problem. | | can someone please help? | | thanks in advance. | | -- | Message posted via DotNetMonster.com | http://www.dotnetmonster.com/Uwe/Forums.aspx/dotnet-vb-net/200606/1 M.R.
Is it right that the forelast row is continuasly overwriten, that is what your code in my idea tells. Cor "m.ra. via DotNetMonster.com" <u16975@uwe> schreef in bericht news:61d8785f00d9a@uwe...Show quoteHide quote > hi. > > ive been using a certain code for updating information from a windows form > to an Access database , and it was handling the addition of new > information > properly until now. > > now suddenly the dataset seems to be reordering the rows in an arbitrary > fashion, and since i use > > ds.tables("form1").rows(ctr-1).item(*column name*) > > to add the data, the information keeps getting added to the wrong row. > moreover, the program picks one row and keeps overwriting the information > ONLY to that one row no matter how many new rows i create, which makes it > weirder still because the variable ctr is defined as > > ctr = ds.tables("form1").rows.count > > i dont have any constraints on my sql select statement when i access the > database - no order by or sort by.ive also checked my code several times > to > see if ive reassigned the ctr value anywhere but i havent, so thats not > the > problem. > > can someone please help? > > thanks in advance. > > -- > Message posted via DotNetMonster.com > http://www.dotnetmonster.com/Uwe/Forums.aspx/dotnet-vb-net/200606/1 |
|||||||||||||||||||||||