Click here to Skip to main content
15,914,163 members
Home / Discussions / C#
   

C#

 
AnswerRe: Accepting user input Pin
tom57200715-May-09 1:22
tom57200715-May-09 1:22 
AnswerRe: Accepting user input Pin
fly90415-May-09 1:30
fly90415-May-09 1:30 
AnswerRe: Accepting user input Pin
OriginalGriff15-May-09 1:35
mveOriginalGriff15-May-09 1:35 
GeneralRe: Accepting user input Pin
Pete O'Hanlon15-May-09 1:41
mvePete O'Hanlon15-May-09 1:41 
GeneralRe: Accepting user input Pin
Henry Minute15-May-09 1:43
Henry Minute15-May-09 1:43 
GeneralRe: Accepting user input Pin
Rajdeep.NET is BACK15-May-09 2:34
Rajdeep.NET is BACK15-May-09 2:34 
GeneralRe: Accepting user input Pin
Dave Kreskowiak15-May-09 2:39
mveDave Kreskowiak15-May-09 2:39 
GeneralRe: Accepting user input Pin
Rajdeep.NET is BACK15-May-09 2:51
Rajdeep.NET is BACK15-May-09 2:51 
GeneralRe: Accepting user input Pin
Dave Kreskowiak15-May-09 4:25
mveDave Kreskowiak15-May-09 4:25 
GeneralRe: Accepting user input Pin
OriginalGriff15-May-09 4:07
mveOriginalGriff15-May-09 4:07 
GeneralRe: Accepting user input Pin
Nagy Vilmos15-May-09 4:32
professionalNagy Vilmos15-May-09 4:32 
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 Pin
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 

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.