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.0DAL+ get Sql Stored Procedure return valueDAL+ get Sql Stored Procedure return value
Previous
 
Next
New Post
10/23/2006 12:39 AM
 

Hello,

I am creating my own module and have added my database and stored procedures to update, delete, insert, select and they all work fine when I call them from my BLL.

Here is the stored procedure, when I execute it it works fine.

ALTER Procedure BrowserInfo2_IPCount

@IID int OUT

As

SET @IID =

(Select COUNT(IPAddress)

from Creations_BrowserInfo2)

RETURN @IID

The problem I am having is retrieving the value of @IID in my BLL.

Here is my BLL

Public Shared Function BrowserInfo2_IPCount() As Integer

Dim cnt As Integer

DataProvider.Instance().ExecuteScalar("BrowserInfo2_IPCount", cnt)

BrowserInfo2_IPCount = cnt

End Function

I always get a 0.

Any help would be very appreciated.

Dan5150


Dan5150
 
New Post
10/23/2006 11:30 AM
 
Well, you return the value in two ways from your SQL (by setting the out variable, and returning it), so there are two ways to get it in code.

First, since you return the value, ExecuteScalar will return it.  Thus, you can use BrowserInfo2_IPCount = CInt(DataProvider.Instance().ExecuteScalar("BrowserInfo2_IPCount", cnt)) to get the value.

Secondly, to get it from the out variable, you will need to turn it into a SqlParameter.  So, it would be:
            Dim param As New SqlParameter("@IID", SqlDbType.Int)
            param.Direction = ParameterDirection.Output
            DataProvider.Instance().ExecuteScalar("BrowserInfo2_IPCount", param)
            BrowserInfo2_IPCount = CInt(param.Value)



Hope if helps!

Brian Dukes
Engage Software
St. Louis, MO
866-907-4002
DNN partner specializing in custom, enterprise DNN development.
 
New Post
10/23/2006 8:58 PM
 

Thanks Brian!

I tried both ways but still get a 0. When I execute the Stored Procedure It ask me for an input for @IID, if I use default I get a zero, if I use any number I get the correct Return_Value.

In my BLL when I create the parameter and add a param.value, I always get the same value I entered back. If I don't add a value the procedure uses default which produces a 0. I have changed my stored procedure to:

ALTER Procedure BrowserInfo2_IPCount

@IID int OUTPUT

As

SET @IID = 12

RETURN @IID

For testing purposes. And changed my function to:

Public Shared Function BrowserInfo2_IPCount() As Integer

Dim param As New SqlParameter("@IID", SqlDbType.Int)

param.Direction = ParameterDirection.Output

DataProvider.Instance().ExecuteScalar("BrowserInfo2_IPCount", param)

BrowserInfo2_IPCount = CInt(param.Value)

End Function

This problem is driving my crazy!

Dan5150


Dan5150
 
New Post
10/24/2006 4:22 AM
 
Isn't it a lot easier than that? Wouldn't this work?


Stored Procedure:

ALTER Procedure BrowserInfo2_IPCount

As

SELECT COUNT(IPAddress)

FROM Creations_BrowserInfo2


BLL Function:

Public Shared Function BrowserInfo2_IPCount() As Integer

   Return CType(DataProvider.Instance().ExecuteScalar("BrowserInfo2_IPCount"), Integer)

End Function

 
New Post
10/24/2006 8:31 AM
 

Thanks Allot coolwave6!

That worked great.

My headache is over!

It seems that if you add a RETURN in the stored procedure, then execute it by scalar it returns a 0.

Dan5150


Dan5150
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0DAL+ get Sql Stored Procedure return valueDAL+ get Sql Stored Procedure return value


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