| |
|
|
|
|
|
|
|
|
|
 |    |  |
 | |  |
 | |  |
 | |  |
 | |  |
 |
|
|
|
I'm really stuck here - I'm trying to return an output param into my custom app from a stored procedure. Here's what I've got . .
SqlProvider
Public Overrides Function Get_Measures(ByVal iD As Integer, ByRef VJan As Double, ByRef VFeb As Double) As IDataReader
Dim oParam1 As New SqlParameter("@ID", SqlDbType.Int)
With oParam1
.Value = iD
.Direction = ParameterDirection.Input
End With
Dim oParam4 As SqlParameter = New SqlParameter("@VJAN", SqlDbType.Float)
oParam4.Direction = ParameterDirection.Output
Dim oParam3 As SqlParameter = New SqlParameter("@VFEB", SqlDbType.Float)
oParam3.Direction = ParameterDirection.Output
Dim lReader As IDataReader = CType(SqlHelper.ExecuteReader(ConnectionString, CommandType.StoredProcedure, DatabaseOwner & ObjectQualifier & "TAM_HO_Goal_MeasuresGet", oParam1, oParam3, oParam4), IDataReader)
VJan = CType(oParam4.Value, Double)
VFeb = CType(oParam3.Value, Double)
Return lReader
End Function
DataProvider
Public MustOverride Function Get_Measures(ByVal iD As Integer, ByRef VJan As Double, ByRef VFeb As Double) As IDataReader
BusinessController
Public Function Get_Measures(ByVal iD As Integer, ByRef VJan As Double, ByRef VFeb As Double) As HoshinInfo
Return CType(CBO.FillObject(DataProvider.Instance().Get_Measures(iD, VJan, VFeb), GetType(HoshinInfo)), HoshinInfo)
End Function
And in my codebehind:
Dim VJan As Double
Dim VFeb As Double
Dim objHoshin As New HoshinController
Dim obj_Goals As HoshinInfo = objHoshin.Get_Measures(CType(lblGoalID.Text, Integer), VJan, VFeb)
txtVJan.Text = CType(obj_Goals.vJan, String)
txtVFeb.Text = CType(obj_Goals.VFeb, String)
My sp comes back correct - but my app gets nothing - ( I do a check for null, so I get a value of 0). Does anyone see the problem??
Please Help! |
|
|
|
 |  |
|
|
|
Actually I managed to do it a little bit different way, my stored procedure is like this:
CREATE PROCEDURE [dbo].[GetUserAttemptCount] @UserID int, AS
DECLARE @RESULT INT
SELECT @RESULT = Count(*) FROM UserAttempts WHERE UserID = @UserID AND
SELECT @RESULT GO
and then I used the following code in my SQLDataProvider:
Return CType(SqlHelper.ExecuteScalar(ConnectionString, DatabaseOwner & ObjectQualifier & GetUserAttempts", userID), Integer)
Bilal Al-Ghazi
Visit My Collection of Photos |
|
|
|
 |  |
|
|
|
Thanks very kindly for your reply, but executescalar is best for returning 1 value. I'm trying to retrieve multiple output parameters. Here's my stored procedure which returns the correct values - just having an issue returning the value within DNN.
ALTER PROCEDURE dbo.TAM_HO_Goal_MeasuresGet (@ID int, @VJAN FLOAT OUTPUT, @VFEB FLOAT OUTPUT) AS DECLARE @JAN FLOAT DECLARE @FEB FLOAT DECLARE @PFEB FLOAT DECLARE @PJAN FLOAT DECLARE @UNIT INT
SELECT @UNIT=Type from TAM_HO_Goals_D where [ID] = @ID
SELECT @JAN=[Jan], @PJAN=[PJan], @Feb=[Feb], @PFEB=[PFeb] from TAM_HO_Goal_Measures where [GoalID]=@ID
if @UNIT = 1 BEGIN
SET @VJAN=COALESCE(@Jan,0)/COALESCE(@PJan,0) * 100 SET @VFEB=COALESCE(@Feb,0)/COALESCE(@PFeb,0) * 100
END
I'm guessing the issue lies within my sqlprovider - but not sure what to do . . . Here's part of it again.
Dim lReader As IDataReader = CType(SqlHelper.ExecuteReader(ConnectionString, CommandType.StoredProcedure, DatabaseOwner & ObjectQualifier & "TAM_HO_Goal_MeasuresGet", oParam1, oParam3, oParam4), IDataReader) <---- here maybe?
VJan = CType(oParam4.Value, Double)
VFeb = CType(oParam3.Value, Double)
Any help would be appreciated! |
|
|
|
 |  |
|
|
|
| Is there a better way to accomplish this? |
|
|
|
 |  |
|
|
|
Hello tadskins,
your stored procedure is fine, the VB-Code not. You are not querying table data, so a datareader must be wrong.
Try this:
Dim param_id As New SqlParameter("id", SqlDbType.Int) param_id.Value = <<your id>> Dim param_vjan As New SqlParameter("vjan", SqlDbType.Float) param_vjan.Direction = ParameterDirection.Output Dim param_vfeb As New SqlParameter("vfeb", SqlDbType.Float) param_vfeb.Direction = ParameterDirection.Output SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & "TAM_HO_Goal_MeasuresGet", _ New Object() {param_id, param_vjan, param_vfeb}) Dim VJan As Double = CType(param_vjan.Value, Double) Dim VFeb As Double = CType(param_vfeb.Value, Double)
Stefan Cullmann - stefan.cullmann [at] dotnetnuke.com
forms & Lists (UDT5.0) will be the next major release of the User Defined Table project. A first Preview is available, though it requires DotnetNuke 5 (Beta 5).
Need to import external data to a UDT? Try http://www.codeplex.com/Csv2UDTImport |
|
|
|
|  |
 | |  |
 | |  |
 | |  |
|  |
| |
 |
|
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.
|
| |
 |
|
|
|
|
|
|
|