Not getting the return value from Stored Procedure.
Enclosed is the stored procedure:
set
ANSI_NULLSONsetQUOTED_IDENTIFIERON
GO
ALTER
PROCEDURE [dbo].[InsertModule](
@Module
nvarchar(MAX))
AS
Begin
SetNOCOUNTONifexists(Select 1From ModulesWhere Module=@Module)Beginreturn-1EndELSEBeginINSERTINTO [dbo].[Modules]([Module])VALUES(@Module)RETURN 0EndEND
This is the calling program:
private
void SubmitButton_Click(object sender,EventArgs e){
sqlConnection1.Open();
if (Module.Length > 0){
SqlCommand cmdModule =newSqlCommand("InsertModule",sqlConnection1);cmdModule.CommandType =
CommandType.StoredProcedure;SqlParameter parInput = cmdModule.Parameters.Add("@Module",SqlDbType.NVarChar);parInput.Direction =
ParameterDirection.Input;parInput.Value = Module;
cmdModule.Parameters.Add(
"@RetVal",SqlDbType.Int,1);cmdModule.Parameters[
"@RetVal"].Direction =ParameterDirection.ReturnValue;cmdModule.ExecuteNonQuery();
int code = (int)cmdModule.Parameters["@RetVal"].Value;if (code == 0){
label8.Text =
"Module Created Successfully";}
else{
System.Windows.Forms.
MessageBox.Show("Create new module Not Successful!");}
}
else{
label8.Text =
"Module can't be blank";}
Module =
"";ModuleNameTextBox.Text =
" ";label8.Text =
" ";sqlConnection1.Close();
}
I can insert the data, but I can't show the sucess message for some unknown reason.
Thanks for the help.

