Small width layout Medium width layout Maximum width layout Small text Medium text Large text
     Search
Downloads Downloads Directory Directory Forums Forums Forge Forge Blogs Blogs        Marketplace Marketplace Careers Program Careers
Community › Forums Register  |  

DotNetNuke Marketplace
  Ads  
OnyakTech
 


  Sponsors  

Meet Our Sponsors

SmarterTools
The Official Microsoft ASP.NET Website
Portal Webhosting - Hosting For Developers
Red-Gate Software
MaximumASP
SourceGear - Tools for Developers
 


DotNetNuke Forums
 
  Forum  General DotNetN...  Extend It! ( Pr...  Getting the @Return_Value to the presentation Layer
Previous Previous
 
Next Next
New Post 8/19/2006 2:40 PM
User is offline John Bolduc
18 posts
10th Ranked


Getting the @Return_Value to the presentation Layer 

I have a StoredProcedure that evaluates the table and if certain conditions are met, completes an Update.  When I run it in the VS2005 Server Explorer it behaves exactly as designed (only updates the table if the conditions are met) and returns "@RETURN_VALUE = 0"(conditions not met) or "@RETURN_VALUE = 1" (conditions met) exactly as I want.  However, when I try to call it from my application it , always updates the table, no matter if the conditions are met or not.  I also obviously don't understand how to pass the @RETURN_VALUE back thru the SqlDataProvider, DataProvider, and Controller file to display to the user the messages I want to. I always ge thte failure message with a successful update.  Is there a tutorial on or example on using @RETURN_VALUE in the DAL, BLL, or anyone willing to give me a hand?

The Stored Procedure (this Works in server Explorer):

ALTER PROCEDURE dbo.[PSLPD_OverTime_SignUp48Count]

(

@ID int,

@ModuleID int,

@Shift nvarchar(50),

@SignedUpUser nvarchar(50),

@CreatedByUser nvarchar(250),

@DateSignedUp datetime

)

AS

DECLARE @48Count Int

SELECT @48Count = COUNT(*)

FROM PSLPD_OverTime

WHERE (ModuleID = @ModuleID) AND (SignedUpUser = @SignedUpUser) AND (Shift = @Shift) AND (CreatedByUser = @CreatedByUser)

AND (DateofShift >= GETDATE()) AND (DATEDIFF(minute, DateEntered, GETDATE()) <= 2880)

UPDATE PSLPD_OverTime

SET SignedUpUser =@SignedUpUser, DateSignedUp = @DateSignedUp

WHERE ID = @ID AND (@48Count < 2)

RETURN @@rowcount

I will post whatever code is needed...

John


John
 
New Post 8/22/2006 7:29 PM
User is offline John Bolduc
18 posts
10th Ranked


Re: Getting the @Return_Value to the presentation Layer 

Affected Rows always comes back as -1, even when the row has been updated.  I added the Return_Value to the *Info.vb in the App_Code folder.  Any hints as to what to add to the sqldataprovider to pass Return_Value back up?

Just a hint...


John
 
New Post 8/22/2006 8:40 PM
User is offline eck two
329 posts
8th Ranked


Re: Getting the @Return_Value to the presentation Layer 
When declaring the function in sqldataprovider, one of the parameter usedin the function definition used to pass back the return value should be declared as "byRef".
 
New Post 8/24/2006 5:02 PM
User is offline John Bolduc
18 posts
10th Ranked


Re: Getting the @Return_Value to the presentation Layer 

I figured it out, here are the answers just in case it will help someone else out.                                                

[QUOTE]jbolduc wrote
 However, when I try to call it from my application it , always updates the table, no matter if the conditions are met or not. 

After I thought about it, it  was obviously a parameter problem. Rechecked and a couple of the parameters needed to perform the count function in sproc were not being provided. Fixed...

Getting  the Return_Value back to the ObjectDataSource Updating Method was a little harder.  Here is the code from SQLDataProvider, DataProvider, and Controller files that made it work.

SqlDataProvider-->

Public Overrides Function PSLPD_OverTime_SignUp48Count(ByVal Id As Integer, ByVal ModuleId As Integer, ByVal Shift As String, ByVal SignedUpUser As String, ByVal CreatedByUser As String, ByVal DateSignedUp As DateTime) As Integer

Dim Return_Value As Integer

Return_Value = SqlHelper.ExecuteNonQuery(ConnectionString, GetFullyQualifiedName("PSLPD_OverTime_SignUp48Count"), Id, ModuleId, Shift, SignedUpUser, CreatedByUser, DateSignedUp)

Return Return_Value

End Function

DataProvider-->

Public MustOverride Function PSLPD_OverTime_SignUp48Count(ByVal Id As Integer, ByVal ModuleId As Integer, ByVal Shift As String, ByVal SignedUpUser As String, ByVal CreatedByUser As String, ByVal DateSignedUp As DateTime) As Integer

Controller-->

<DataObjectMethod(DataObjectMethodType.Update, True)> _

Public Shared Function OverTime_SignUp48Count(ByVal objTest As OverTimeInfo) As Integer

Dim Return_Value As Integer

Return_Value = DataProvider.Instance.PSLPD_OverTime_SignUp48Count(objTest.ID, objTest.ModuleId, objTest.Shift, objTest.SignedUpUser, objTest.CreatedByUser, objTest.DateSignedUp)

Return Return_Value

End Function

Hope it helps.. John


John
 
Previous Previous
 
Next Next
  Forum  General DotNetN...  Extend It! ( Pr...  Getting the @Return_Value to the presentation Layer
 


Forum Policy

These Discussion Forums are dedicated to the discussion of the DotNetNuke Web Application Framework.

For the benefit of the community and to protect the integrity of the project, please observe the following posting guidelines:

1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DotNetNuke.
2. Discussion or promotion of DotNetNuke product releases under a different brand name are strictly prohibited.
3. No Flaming or Trolling.
4. No Profanity, Racism, or Prejudice.
5. Site Moderators have the final word on approving/removing a thread or post or comment.
6. English language posting only, please.

 


SSL Enabled and Amazingly FAST...
SSL enable your DNN web site with SSLRedirect, compress your DNN web site HTTP data flow by up to 75%-90% with HttpCompressionAgent, and monitor your DNN web site's performance with WebKeepAlive...
www.sanibellogic.com
Ultra Media Gallery & Video Gallery
The most popular photo gallery and video gallery module. with Flash interface.
www.bizmodules.net
WDK Solutions
Quality modules for the DotNetNuke community. Check out our 'wild' modules!
wdkns.com

DotNetNuke Corporation   Terms Of Use  Privacy Statement
DotNetNuke®, DNN®, and the DotNetNuke logo are trademarks of DotNetNuke Corporation
Hosted by MaximumASP