.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> ADO.NET >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Get The OUTPUT Paramete Value from SP Using Dot Net

Posted By:Prasanti Prusty       Posted Date: February 24, 2010    Points: 10    Category: ADO.NET    URL: http://www.dotnetspark.com  

Get The OUTPUT Paramete Value from SP Using Dot Net using asp.net. This code can be used to get the data from database using Out parameter
 


Imports System.Data
Imports System.Data.SqlClient

Partial Class SP
    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try

            Dim Con As New SqlConnection
            Con.ConnectionString = "Password=RR;Persist Security Info=True;User ID=RR;Initial Catalog=RR;Data Source=RR"
            Con.Open()
            Dim INparam, OutPram As New SqlParameter
            INparam.Direction = ParameterDirection.Input
            INparam.SqlDbType = SqlDbType.Int
            INparam.ParameterName = "@ID"
            INparam.Size = 20
            INparam.Value = Textbox1.text

            OutPram.Direction = ParameterDirection.Output
            OutPram.SqlDbType = DbType.String
            OutPram.ParameterName = "@Name"
            OutPram.Size = 200

            Dim com As New SqlCommand
            com.Connection = Con
            com.CommandType = CommandType.StoredProcedure
            com.CommandText = "spGetOutput"
            com.Parameters.Add(INparam)
            com.Parameters.Add(OutPram)
            com.ExecuteNonQuery()

            Label1.Text = OutPram.Value()

        Catch ex As Exception

        End Try
    End Sub

End Class


     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend