troubleshooting Question

SQL Output Parameter in Winforms application

Avatar of ALawrence007
ALawrence007 asked on
Microsoft SQL Server.NET ProgrammingVisual Basic.NET
3 Comments1 Solution248 ViewsLast Modified:

I have a stored procedure that gives me an output parameter of Scope_Identity(). My vb code that I have currently does not capture that Scope_Identity(), instead it always gives me an output param of 1. Can someone please let me know what I am doing wrong? Here is my code so far:

Dim item As New BallMaster
Dim New_ID As Integer
item.CustomerID = ACBox.SelectedValue
item.BallTotal = ctTBox.Text
Dim BallDetailsParam(2) As SqlParameter
BallDetailsParam(0) = New SqlParameter("@CustomerID", item.CustomerID)
BallDetailsParam(1) = New SqlParameter("@BallTotal", item.BallTotal)
BallDetailsParam(2) = New SqlParameter("@BallTableID", SqlDbType.Int)
BallDetailsParam(2).Direction = ParameterDirection.Output
BallDetailsParam(2).Value = item.BallTableID
Dim i As Integer
For i = 0 To BallDetailsParam.Length - 1
command.CommandText = "BallMaster"
New_ID = item.BallTableID

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros