Click here to Skip to main content
15,905,587 members
Home / Discussions / C#
   

C#

 
GeneralRe: Threading? Pin
Ennis Ray Lynch, Jr.3-Feb-09 16:21
Ennis Ray Lynch, Jr.3-Feb-09 16:21 
GeneralRe: Threading? Pin
benjamin yap3-Feb-09 16:26
benjamin yap3-Feb-09 16:26 
GeneralRe: Threading? Pin
Ennis Ray Lynch, Jr.3-Feb-09 16:55
Ennis Ray Lynch, Jr.3-Feb-09 16:55 
QuestionC# ID Generator... Pin
Illegal Operation3-Feb-09 14:27
Illegal Operation3-Feb-09 14:27 
AnswerRe: C# ID Generator... Pin
Ennis Ray Lynch, Jr.3-Feb-09 14:59
Ennis Ray Lynch, Jr.3-Feb-09 14:59 
AnswerRe: C# ID Generator... Pin
Expert Coming3-Feb-09 16:43
Expert Coming3-Feb-09 16:43 
GeneralRe: C# ID Generator... Pin
fazal201019-Sep-09 18:34
fazal201019-Sep-09 18:34 
AnswerRe: C# ID Generator... Pin
_Maxxx_3-Feb-09 18:52
professional_Maxxx_3-Feb-09 18:52 
Are you saying you want to stop SQL auto incrementing and instead do it yourself? Or, are you saying that you just want to find out what the ID of the previously inserted record was?

If the former, you need to be careful - as if multiple users access the db while you are doing your 'next number' calculation, t may end up trying to insert a duplicate value - much better to let SQL handle that for you.

To get the value of the last inserted identiy, use the SQL function SCOPE_IDENITY(). e.g.
Insert into Person (PersonId, Person) values (@PersonId, @Person);
Select SCOPE_IDENTITY();

then use

int newId = Convert.ToInt32(db.ExecuteScalar(dbCommand));

which will give your program back the ID just inserted.(I'm guessing here that your table has an Id column which is auto-incremented, and a PersonId column which is created somehow else.

(on re-reading this

Illegal Operation wrote:
incriment it by 1 when inserting the PersonId.


I'm not sure what you mean by 'inserting the PersonId'?

___________________________________________
.\\axxx
(That's an 'M')

AnswerRe: C# ID Generator... Pin
raghsingh3-Feb-09 23:32
raghsingh3-Feb-09 23:32 
AnswerRe: C# ID Generator... Pin
Wendelius4-Feb-09 8:13
mentorWendelius4-Feb-09 8:13 
QuestionWeb query in c# Pin
bfis1081373-Feb-09 12:57
bfis1081373-Feb-09 12:57 
AnswerRe: Web query in c# Pin
Guffa3-Feb-09 13:08
Guffa3-Feb-09 13:08 
QuestionGsm Redialing Problem Pin
ajorge20083-Feb-09 11:22
ajorge20083-Feb-09 11:22 
QuestionWPF is easy to learn? Pin
Seraph_summer3-Feb-09 9:50
Seraph_summer3-Feb-09 9:50 
AnswerRe: WPF is easy to learn? Pin
Guffa3-Feb-09 10:29
Guffa3-Feb-09 10:29 
GeneralRe: WPF is easy to learn? Pin
MadArtSoft3-Feb-09 23:52
MadArtSoft3-Feb-09 23:52 
Questionget native resolution of LCD display Pin
LordZoster3-Feb-09 9:05
LordZoster3-Feb-09 9:05 
AnswerRe: get native resolution of LCD display Pin
Wendelius3-Feb-09 9:32
mentorWendelius3-Feb-09 9:32 
GeneralRe: get native resolution of LCD display Pin
Jon Rista3-Feb-09 10:33
Jon Rista3-Feb-09 10:33 
GeneralRe: get native resolution of LCD display Pin
Wendelius3-Feb-09 10:48
mentorWendelius3-Feb-09 10:48 
GeneralRe: get native resolution of LCD display Pin
LordZoster3-Feb-09 10:59
LordZoster3-Feb-09 10:59 
GeneralRe: get native resolution of LCD display Pin
Wendelius3-Feb-09 11:03
mentorWendelius3-Feb-09 11:03 
AnswerRe: get native resolution of LCD display Pin
harold aptroot3-Feb-09 11:49
harold aptroot3-Feb-09 11:49 
AnswerRe: get native resolution of LCD display Pin
Expert Coming3-Feb-09 16:45
Expert Coming3-Feb-09 16:45 
GeneralRe: get native resolution of LCD display Pin
LordZoster3-Feb-09 20:50
LordZoster3-Feb-09 20:50 

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.