Click here to Skip to main content
15,891,730 members
Home / Discussions / C#
   

C#

 
GeneralRe: Accepting user input Pin
Baeltazor16-May-09 1:12
Baeltazor16-May-09 1:12 
AnswerRe: Accepting user input Pin
EliottA15-May-09 3:39
EliottA15-May-09 3:39 
AnswerRe: Accepting user input Pin
Vasudevan Deepak Kumar15-May-09 5:17
Vasudevan Deepak Kumar15-May-09 5:17 
Questioncode for Autogerate number in a datagrid field Pin
jaikumar 215-May-09 0:58
jaikumar 215-May-09 0:58 
AnswerRe: code for Autogerate number in a datagrid field Pin
Henry Minute15-May-09 1:39
Henry Minute15-May-09 1:39 
GeneralRe: code for Autogerate number in a datagrid field Pin
MumbleB15-May-09 1:57
MumbleB15-May-09 1:57 
AnswerRe: code for Autogerate number in a datagrid field Pin
KIDYA15-May-09 2:02
KIDYA15-May-09 2:02 
GeneralRe: code for Autogerate number in a datagrid field Pin
Dave Kreskowiak15-May-09 4:33
mveDave Kreskowiak15-May-09 4:33 
There are so many things wrong with this code it's silly. Thankfully, I will never have to follow you and support/cleanup your code.

Your simple little algorithm does work, though VERY inefficiently, and only when there is but a single user of your database.

When you expand this so more than one user is creating a new record at the same time, your code breaks, so severely, it corrupts the database, puts an enormous load on the SQL server and network carrying the data, and will get slower and slower as the number of records in the table climbs.

Ask youself this. What if a second client ran this same code at nearly the same time? Both clients would get the same last record ID, and both add 1 to it, and both create a new record with the same new ID, but different data. Congratulations! You just corrupted your database to the point where you can't easily recover, if at all!

Your application should never generate it's own sequential record ID's. This should be left up to the database itself, when concurrancy issues like this can be controlled.


A guide to posting questions on CodeProject[^]



Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic
     2006, 2007, 2008




QuestionAutoGenerateNumber Pin
jaikumar 215-May-09 0:57
jaikumar 215-May-09 0:57 
AnswerRe: AutoGenerateNumber Pin
Ashfield15-May-09 1:09
Ashfield15-May-09 1:09 
AnswerRe: AutoGenerateNumber Pin
Rajdeep.NET is BACK15-May-09 1:10
Rajdeep.NET is BACK15-May-09 1:10 
GeneralRe: AutoGenerateNumber PinPopular
Ashfield15-May-09 1:25
Ashfield15-May-09 1:25 
GeneralRe: AutoGenerateNumber Pin
MumbleB15-May-09 1:59
MumbleB15-May-09 1:59 
Questionmemset and FLOAT2IEEE? Pin
dec8215-May-09 0:48
dec8215-May-09 0:48 
AnswerRe: memset and FLOAT2IEEE? Pin
Anthony Mushrow15-May-09 1:34
professionalAnthony Mushrow15-May-09 1:34 
QuestionHow to delete datarow from datatable according to the gridview's checkbox? Pin
cocoonwls14-May-09 23:59
cocoonwls14-May-09 23:59 
AnswerRe: How to delete datarow from datatable according to the gridview's checkbox? Pin
Henry Minute15-May-09 1:43
Henry Minute15-May-09 1:43 
GeneralRe: How to delete datarow from datatable according to the gridview's checkbox? Pin
cocoonwls17-May-09 18:04
cocoonwls17-May-09 18:04 
QuestionHow to know Acrobat Reader Running Instance ? Pin
svt gdwl14-May-09 22:51
svt gdwl14-May-09 22:51 
AnswerRe: How to know Acrobat Reader Running Instance ? Pin
Giorgi Dalakishvili14-May-09 23:10
mentorGiorgi Dalakishvili14-May-09 23:10 
GeneralRe: How to know Acrobat Reader Running Instance ? Pin
svt gdwl15-May-09 1:18
svt gdwl15-May-09 1:18 
Questionmobile application Pin
hotthoughtguy14-May-09 22:41
hotthoughtguy14-May-09 22:41 
JokeRe: mobile application Pin
Mycroft Holmes14-May-09 22:47
professionalMycroft Holmes14-May-09 22:47 
GeneralRe: mobile application Pin
hotthoughtguy14-May-09 23:18
hotthoughtguy14-May-09 23:18 
QuestionDrag-and-drop of string between two lists Pin
tom57200714-May-09 22:21
tom57200714-May-09 22:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.