View Single Post
  #2 (permalink)  
Old 11-11-2008, 1:49 AM
wstevens wstevens is offline
VB.NET Forum Newbie
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: May 2008
Location: South Africa PTA
Posts: 16
Reputation: 25
wstevens is on a distinguished programming path ahead
Default

Hi all "Solution"

I hope this helps everybody else having the same problem. ScalarQueriesTableAdapter returning 0 value from a stored procedure

Create your stored procedure with a RETURN value as normal. Then open dataset designer and drag a QueriesTableAdapter onto the design screen. Create a query and use existing stored procedure you created.

Then edit the Partial class for the named query and add the code below.

Code:
  Public Function GetReturnValue(ByVal commandIndex As Integer) As Object

            Return Me._commandCollection(commandIndex).Parameters(0).Value

        End Function

Your VB code will now look like this.

Code:
Dim scalarQueriesTableAdapter As DSMetricsTableAdapters.QueriesTableAdapter
        scalarQueriesTableAdapter = New DSMetricsTableAdapters.QueriesTableAdapter
        scalarQueriesTableAdapter.CheckMetrics("Department", "tbl_Metrics")
        Dim returnValue As Integer
        returnValue = scalarQueriesTableAdapter.GetReturnValue(0)

I hope this helps somebody

Last edited by JohnH; 11-19-2008 at 7:38 PM. Reason: formatted post for readability
Reply With Quote