[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

access stored proc value from vb.net

Posted on 2012-12-28
2
Medium Priority
?
184 Views
Last Modified: 2013-01-03
I have a stored proc named  spTierCredits_PlayerID
(I am passing in an input parameter named playerid)

 that does a bunch of processing to dettermine an end value for

DECLARE @TotalTableSlotTierCredits AS DECIMAL(18, 2);

....
 

SET @TotalTableSlotTierCredits = isnull(@TotalTableTierCredits,0) + isnull(@TotalSlotTierCredits,0)

From what I have read I should be able to get this in a vb.net app without defining
@TotalTableSlotTierCredits  as an output variable.

I am having some trouble though


 strConn = ConfigurationManager.ConnectionStrings("DBConnectStringPlayerTierInfo").ConnectionString
            Dim cn As New SqlClient.SqlConnection(strConn)

            cn.Open()

            Dim strsql As String
            strsql = "spTierCredits_PlayerID"
            Dim param As New SqlClient.SqlParameter
            Dim cmd As New SqlClient.SqlCommand(strsql, cn)
            cmd.CommandType = CommandType.StoredProcedure
            param = cmd.Parameters.Add("@playerid", SqlDbType.VarChar, 0)
         
            cmd.Parameters(0).Value = intPlayerid
            Dim rdr As SqlClient.SqlDataReader = cmd.ExecuteReader()

            If rdr.Read() = False Then
                lblFeedback.Text = "No Player Id found for card swiped"
                lblFeedback.CssClass = "errorMsg"
                divFeedbackHolder.Visible = True
                lblTotalTierCreditsValue.Text = ""
                rdr.Close()
                txtCardID.Text = ""
                Exit Sub
            Else
                intPlayerid = rdr.Item("PlayerID")
            End If

            rdr.Close()

            cn.Close()
            txtCardID.Text = ""
0
Comment
Question by:johnnyg123
2 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 38728223
Does your sproc return this value?
0
 
LVL 18

Accepted Solution

by:
Jerry Miller earned 2000 total points
ID: 38732865
Be sure and specify an OUTPUT parameter:

http://msdn.microsoft.com/en-us/library/ms188655.aspx
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question