Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Getting the @Return_Value to the presentation LayerGetting the @Return_Value to the presentation Layer
Previous
 
Next
New Post
8/19/2006 4:40 PM
 

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 9:29 PM
 

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 10:40 PM
 
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 7:02 PM
 

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
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Getting the @Return_Value to the presentation LayerGetting the @Return_Value to the presentation Layer


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, 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 DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out