Advertisement

07.16.2008 at 01:13AM PDT, ID: 23568764
[x]
Attachment Details

How to get the value from a stored procedure using vb.nt

Asked by PaulEll in Microsoft Visual Basic.Net, MS SQL Server

Tags: , , , , ,

Hi there,

I'm very new to VB.net and am playing around with stored procedured.

I have attached a code snippet and the the stored procedure.
Basically I am trying get the value MySum from the stored procedure and to populate
a text box with its value.

Thanks in advance
PaulStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
Dim MyConn As New SqlConnection(MyConnString)
        Dim MyCmd As SqlCommand = MyConn.CreateCommand()
        Dim MyVar As String = "750 x 16"
 
        With MyCmd
            .CommandText = "sp_mod0010"
            .CommandType = CommandType.StoredProcedure
            .Connection = MyConn
            .Parameters.Add("@tyresize", SqlDbType.Char, 20, MyVar)
            .Parameters.Add("MySum", SqlDbType.Int)
            .Parameters("MySum").Direction = ParameterDirection.Output
        End With
 
        Try
            MyCmd.ExecuteNonQuery()
        Catch exp As SqlClient.SqlException
            MsgBox(exp.Message)
        End Try
 
        'display output parameter 
        TextBox1.Text = MyCmd.Parameters("MySum").Value
 
***********************************************************************
 
ALTER PROCEDURE [dbo].[sp_mod0010] 
 
@tyresize as nvarchar(20)
AS
BEGIN
SET NOCOUNT ON
select sum(quantity) as MySum from modtaskitems where tyresize=@tyresize and modsaleid is null
 
END
[+][-]07.16.2008 at 01:15AM PDT, ID: 22014072

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.16.2008 at 01:15AM PDT, ID: 22014077

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.16.2008 at 01:27AM PDT, ID: 22014131

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.16.2008 at 01:45AM PDT, ID: 22014197

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.16.2008 at 01:56AM PDT, ID: 22014262

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.16.2008 at 01:59AM PDT, ID: 22014275

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.16.2008 at 02:36AM PDT, ID: 22014407

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.16.2008 at 02:37AM PDT, ID: 22014416

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.16.2008 at 02:38AM PDT, ID: 22014419

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Visual Basic.Net, MS SQL Server
Tags: Microsoft, Visual Studio, 2008, Accessing a variable in a stored procedure, Visual Basic, .net
Sign Up Now!
Solution Provided By: angelIII
Participating Experts: 2
Solution Grade: A
 
 
[+][-]07.16.2008 at 03:14AM PDT, ID: 22014543

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.16.2008 at 03:21AM PDT, ID: 22014566

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628