•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 456,556 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,456 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 5199 | Replies: 2 | Solved
![]() |
I am trying to get a value from a stored procedure:
I should be getting a 1 or 2, but keep getting a 0 with this code:
I would really like to get the printed statements, but will settle for anything at this point.
SQL Syntax (Toggle Plain Text)
SET @RowCount = @@RowCount IF @RowCount = 1 BEGIN SET @Ret = 1 PRINT 'Insert a success' END IF isnull(@RowCount,0) = 0 BEGIN SET @Ret = 2 PRINT 'Insert a failure.. Terminating Proc...' RETURN END
I should be getting a 1 or 2, but keep getting a 0 with this code:
C# Syntax (Toggle Plain Text)
cmd.Parameters.Add("@Ret", SqlDbType.Int); cmd.Parameters["@Ret"].Direction = ParameterDirection.ReturnValue; conn.Open(); int ReturnedVal=1; cmd.ExecuteNonQuery(); ReturnedVal = (int)cmd.Parameters["@Ret"].Value; conn.Close(); CountCheck.Text = Convert.ToString(ReturnedVal);
I would really like to get the printed statements, but will settle for anything at this point.
Thanks for responding... I am using 2.0 and actually got what I needed from another forum, but if you have any other comments let me know... The initial issue was solved by adding the @Ret after the RETURN in the if statements.
Here is the solution:
Here is the solution:
SQL Syntax (Toggle Plain Text)
SET @RowCount = @@RowCount IF @RowCount = 1 BEGIN SET @Ret = 1 PRINT 'Insert a success' END IF isnull(@RowCount,0) = 0 BEGIN SET @Ret = 2 PRINT 'Insert a failure.. Terminating Proc...' RETURN @Ret END
C# Syntax (Toggle Plain Text)
cmd.Parameters.Add("@Ret", SqlDbType.Int); cmd.Parameters["@Ret"].Direction = ParameterDirection.Output; cmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int); cmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue; conn.Open(); int ReturnedVal=1; cmd.ExecuteNonQuery(); ReturnedVal = (int)cmd.Parameters["@Ret"].Value; int AlsoReturnedVal=(int)cmd.Parameters["@RETURN_VALUE"].Value; conn.Close(); CountCheck.Text = Convert.ToString(ReturnedVal);
Last edited by rrocket : Oct 18th, 2007 at 1:06 pm.
![]() |
•
•
•
•
•
•
•
•
DaniWeb ASP.NET Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- ASP.NET Registration Page (ASP.NET)
- using stored procedure in C++ (C++)
- Can return a Stored Procedure Recordset (MS SQL)
- Help with Stored Procedure (MS SQL)
- how do I run a "disconnected" stored procedure (MS SQL)
- ASP.net/Stored Proc & Login Verification (ASP.NET)
- Stored procedure call with ADO (C)
Other Threads in the ASP.NET Forum
- Previous Thread: Add value manually into DropDownList, CheckBoxList and RadioButtonList.
- Next Thread: Print Reporting services report to papers.


Linear Mode