I have found a solution to this problem, but I don't know if I can explain completly why. Based on the number of replies this question received I would guess that the disconnected dataset stuff is not well understood.
What I finally found after several days testing various combinations of things is that the dataset wizard setup different properties for the columns in the dataset. In the database the Identity properties defaults were used. Identity Increment = 1, and Identity Seed = 1. But when the dataset was generated the AutoIncrementSeed was 0 and the AutoInrementStep was 1.
I am not sure of how I genereated the dataset, but during testing I stripped the original program down to nothing but the single table with an ID column for the PK and a text column. I used a loop to generate values for the text column for 100 rows. I did delete and regenerate the dataset and database several times to see if I could make the Update work. I then generated a new application from scratch that was virtually identical and it worked fine. Then through extensive used of the watch window I compared step by step every value generated and notice that the newrow() method of the original application was creating a dataset row with an ID of 0. In the immediate window I changed this value to 1, and it worked. In the scratch version the ID value was generated as 1. Then I checked the dataset properties for the ID field of the new version in the dataset designer and found the the AutoIncrementSeed was 1, not 0.
I then when to the original applications, including the version downloaded for the video series from microsoft, and changed this property from 0 to 1. I also reset the database property by setting the Identity property to no and back to yes. Now they all work.
I also fixed the dupe check. The author had removed quotes from the title and also took the first 50 character substring for longer titles before storing in the database. It was these changed titles that were not found in the dupe check. I modified the dupe check to use the adjusted title in the comparison and no more dupes.
If anyone understands more about the dataset/database Seed thing, I still have questions as to why it didn't work and why my solution worked. In my initial troubleshooting I created a scratch program that worked and the dataset seed was 0.
Thanks for your time.
|