Click here to Skip to main content
15,890,670 members
Home / Discussions / C#
   

C#

 
GeneralRe: It is Working... with using MSHTML; Pin
emran83428-Jan-06 5:39
emran83428-Jan-06 5:39 
QuestionAutoScroll Pin
Sabry190523-Jan-06 7:31
Sabry190523-Jan-06 7:31 
AnswerRe: AutoScroll Pin
tarasn23-Jan-06 11:38
tarasn23-Jan-06 11:38 
GeneralRe: AutoScroll Pin
Sabry190524-Jan-06 0:07
Sabry190524-Jan-06 0:07 
QuestionC# Stored Procs Pin
niceguyeddie199923-Jan-06 6:09
niceguyeddie199923-Jan-06 6:09 
AnswerRe: C# Stored Procs Pin
Xodiak23-Jan-06 6:21
Xodiak23-Jan-06 6:21 
GeneralRe: C# Stored Procs Pin
niceguyeddie199923-Jan-06 6:24
niceguyeddie199923-Jan-06 6:24 
GeneralRe: C# Stored Procs Pin
Colin Angus Mackay23-Jan-06 7:28
Colin Angus Mackay23-Jan-06 7:28 
He means that in your stored procedure, instead of using a return that you do a
SELECT @rc
If you don't SELECT anything else in the stored procedure then this can work quite well. In your C# application you would use ExecuteScalar() on the SqlCommand class in order to retrieve the result, like this:
SqlCommand cmd = new SqlCommand();
cmd.Connection = myConnection;
cmd.CommandText = "MyStoredProcName";
cmd.CommandType = CommandType.StoredProcedure;
int result = (int)cmd.ExecuteScalar()


Of course, if you are already returning other data from the stored procedure, this SELECT becomes a bit more difficult to manage. In that case you can retrieve the result by using a parameter to get the result of the RETURN statement.

In your command object add this to the list of parameters:
SqlParameter returnParam= new SqlParameter("RETURN_VALUE",SqlDbType.Int);
returnParam.Direction = ParameterDirection.ReturnValue;
cmd.Parameters.Add(returnParam);
After you execute your stored procedure you can get the return value like this:
int result = (int)(cmd.Parameters["RETURN_VALUE"].Value)
// or, if returnParam is still in scope
int result = (int)returnParam.Value


Does this help?

ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell


-- modified at 13:30 Monday 23rd January, 2006

GeneralRe: C# Stored Procs Pin
Colin Angus Mackay23-Jan-06 7:10
Colin Angus Mackay23-Jan-06 7:10 
GeneralRe: C# Stored Procs Pin
Xodiak23-Jan-06 9:27
Xodiak23-Jan-06 9:27 
GeneralRe: C# Stored Procs Pin
Dave Kreskowiak23-Jan-06 11:04
mveDave Kreskowiak23-Jan-06 11:04 
GeneralRe: C# Stored Procs Pin
Colin Angus Mackay23-Jan-06 11:09
Colin Angus Mackay23-Jan-06 11:09 
AnswerRe: C# Stored Procs Pin
Guffa23-Jan-06 9:45
Guffa23-Jan-06 9:45 
GeneralRe: C# Stored Procs Pin
niceguyeddie199924-Jan-06 3:13
niceguyeddie199924-Jan-06 3:13 
QuestionCPPP (Confused Performance Profiling Practices)?! Pin
NewtonVer223-Jan-06 6:03
NewtonVer223-Jan-06 6:03 
AnswerRe: CPPP (Confused Performance Profiling Practices)?! Pin
Dave Kreskowiak23-Jan-06 6:17
mveDave Kreskowiak23-Jan-06 6:17 
AnswerRe: CPPP (Confused Performance Profiling Practices)?! Pin
Daniel Grunwald23-Jan-06 7:43
Daniel Grunwald23-Jan-06 7:43 
Questiondetect if tcp connection dropped/aborted Pin
batmanAgen23-Jan-06 4:49
batmanAgen23-Jan-06 4:49 
AnswerRe: detect if tcp connection dropped/aborted Pin
Dario Solera23-Jan-06 5:51
Dario Solera23-Jan-06 5:51 
AnswerRe: detect if tcp connection dropped/aborted Pin
leppie23-Jan-06 6:27
leppie23-Jan-06 6:27 
AnswerRe: detect if tcp connection dropped/aborted Pin
mcljava23-Jan-06 10:39
mcljava23-Jan-06 10:39 
QuestionPortal Development Pin
student_rhr23-Jan-06 4:48
student_rhr23-Jan-06 4:48 
AnswerRe: Portal Development Pin
Michael Flanakin23-Jan-06 5:52
Michael Flanakin23-Jan-06 5:52 
GeneralRe: Portal Development Pin
student_rhr23-Jan-06 6:14
student_rhr23-Jan-06 6:14 
AnswerRe: Portal Development Pin
Michael Flanakin23-Jan-06 7:33
Michael Flanakin23-Jan-06 7:33 

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.