Role ID behaves differently between Windows forms and Web

Role ID behaves differently between Windows forms and Web

Old forum URL: forums.lhotka.net/forums/t/3882.aspx


CyclingFoodmanPA posted on Sunday, November 11, 2007

Ok, I thought I made a mistake in my app, however the same thing happens in the ProjectTracker application.  When I add a new Role in windows form and do not select and Id, I get the next highest Id and when the record is saved to the DB it has that Id.  However, when I add a role in the web application, it initially shows up as having the next available Id, because the get is executed and it goes through the gyrations of finding the next highest Id.  However, what is actually written to the database is an Id of 0 and the name I entered.  I didn't discover it until I was working on my own application and it happened and I thought I did something wrong.  After debugging for a while I decided to try adding a Role and the same thing happened.  I put the statement _id = Id; in a few places when I create a new Role, however, I ended up getting errors that the object had not been created yet.

Has this happened to anyone else yet and if so, what did you do to fix it.  I thought it would be pretty easy to fix, but I haven't figured it out yet and I don't want to do something that would really mess things up!  So, any help would be greatly appreciated.

Thank you in advance.

 

 

 

CyclingFoodmanPA replied on Sunday, November 11, 2007

Ok, I found something that worked, however, I am always nervious about messing with Rocky's logic as  he is usually right on.  What I did was on the DoInsertUpdate routine, I changed
cm.Parameters.AddWithValue("@id", _id);   to
cm.Parameters.AddWithValue("@id", Id); which executes the get property of the Id to acquire the next Id.  I am confused as to why this works as the Id that displays on the GridView is correct so I am not sure what I am missing elswhere, but it works.  So, if anyone has any other ideas, just continue to reply and you might have a better and more elegant method to fix this.

Thank you.

 

 

 

Copyright (c) Marimer LLC