Click here to Skip to main content
15,881,588 members
Home / Discussions / C#
   

C#

 
GeneralRe: problem to make a second recording Pin
ago248619-Mar-20 3:04
ago248619-Mar-20 3:04 
GeneralRe: problem to make a second recording Pin
OriginalGriff19-Mar-20 3:22
mveOriginalGriff19-Mar-20 3:22 
GeneralRe: problem to make a second recording Pin
ago248619-Mar-20 3:27
ago248619-Mar-20 3:27 
QuestionRe: problem to make a second recording Pin
ZurdoDev19-Mar-20 3:51
professionalZurdoDev19-Mar-20 3:51 
QuestionHow to solve 100 Doors Kata using TDD in C# Pin
User-862169518-Mar-20 5:30
User-862169518-Mar-20 5:30 
AnswerRe: How to solve 100 Doors Kata using TDD in C# Pin
Bohdan Stupak19-Mar-20 5:12
professionalBohdan Stupak19-Mar-20 5:12 
Questionproblem retrieving info from one table to insert it into another Pin
ago248618-Mar-20 3:13
ago248618-Mar-20 3:13 
AnswerRe: problem retrieving info from one table to insert it into another Pin
OriginalGriff18-Mar-20 3:50
mveOriginalGriff18-Mar-20 3:50 
First off, you cannot assume that the last INSERT you did is the last INSERT done by the system - if you have multiple users then their INSERTS can happen at any time. So instead of a separate SELECT to return the maximum value issue a combination command which does the INSERT and returns the value of the IDENTITY field:
SQL
INSERT INTO ...; SELECT SCOPE_IDENTITY();
And it will return the IDENTITY vlaue associated with your INSERT as a scalar value.

This is assuming that the commandes table you speak of is actually the detail_command you describe at the top of your question - but if it isn't, then that would explain why you are having trouble with getting it to work ...

Oh, and BTW: I think we've mentioned that you shouldn't recycle SqlConnections before - create them in a using block and they will be Disposed correctly when you are finished with them.
If you must faff with them like you are, then don't close the connection in the main code and the catch block - add a finally block to your try and close it there.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!

GeneralRe: problem retrieving info from one table to insert it into another Pin
ago248618-Mar-20 4:11
ago248618-Mar-20 4:11 
GeneralRe: problem retrieving info from one table to insert it into another Pin
OriginalGriff18-Mar-20 4:17
mveOriginalGriff18-Mar-20 4:17 
GeneralRe: problem retrieving info from one table to insert it into another Pin
ago248618-Mar-20 4:24
ago248618-Mar-20 4:24 
GeneralRe: problem retrieving info from one table to insert it into another Pin
OriginalGriff18-Mar-20 5:01
mveOriginalGriff18-Mar-20 5:01 
GeneralRe: problem retrieving info from one table to insert it into another Pin
ago248618-Mar-20 5:12
ago248618-Mar-20 5:12 
GeneralRe: problem retrieving info from one table to insert it into another Pin
OriginalGriff18-Mar-20 5:13
mveOriginalGriff18-Mar-20 5:13 
GeneralRe: problem retrieving info from one table to insert it into another Pin
OriginalGriff18-Mar-20 5:16
mveOriginalGriff18-Mar-20 5:16 
GeneralRe: problem retrieving info from one table to insert it into another Pin
ago248618-Mar-20 5:30
ago248618-Mar-20 5:30 
GeneralRe: problem retrieving info from one table to insert it into another Pin
ago248618-Mar-20 5:33
ago248618-Mar-20 5:33 
GeneralRe: problem retrieving info from one table to insert it into another Pin
OriginalGriff18-Mar-20 5:39
mveOriginalGriff18-Mar-20 5:39 
GeneralRe: problem retrieving info from one table to insert it into another Pin
ago248618-Mar-20 5:42
ago248618-Mar-20 5:42 
GeneralRe: problem retrieving info from one table to insert it into another Pin
OriginalGriff18-Mar-20 5:52
mveOriginalGriff18-Mar-20 5:52 
GeneralRe: problem retrieving info from one table to insert it into another Pin
ago248618-Mar-20 5:56
ago248618-Mar-20 5:56 
GeneralRe: problem retrieving info from one table to insert it into another Pin
OriginalGriff18-Mar-20 6:01
mveOriginalGriff18-Mar-20 6:01 
GeneralRe: problem retrieving info from one table to insert it into another Pin
Luc Pattyn18-Mar-20 6:04
sitebuilderLuc Pattyn18-Mar-20 6:04 
GeneralRe: problem retrieving info from one table to insert it into another Pin
OriginalGriff18-Mar-20 6:11
mveOriginalGriff18-Mar-20 6:11 
GeneralRe: problem retrieving info from one table to insert it into another Pin
ago248618-Mar-20 6:51
ago248618-Mar-20 6:51 

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.