How to read output parameter returned from a function as sqlDataReader

V

vengala s reddy

Code:
-------------------------------------------------------------------------------'stored
procedure
CREATE PROCEDURE SP_Test( @id as varchar(50), @supname as varchar(50)
output ) as
Declare @sid as varchar(10)

select lastname +''+firstname from employees where id = @id
select @sid = supervisor from employees where id = @id
select @supname = lastname +''+firstname from employees where
supervisor = @sid
GO
-------------------------------------------------------------------------------'presentation
<%@ Page Language="vb" Inherits="TESTING.Test"%>
<%@ Import Namespace="System.Data.SqlClient" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>WebForm1</title>
</head>
<script language="vb" runat="server">
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs)
Dim obj as New TESTING.Test()
dim dr as SqlDataReader = obj.CheckSubmitFlags("7")

if dr.Read() then
response.write(dr(2)) < HOW TO DISPLAY 2ND OUTPUT PARM HERE?
end if

End Sub
</script>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
</form>
</body>
</html>
-------------------------------------------------------------------------------'Namespace
mports System
Imports System.Data.OleDb
Imports System.Data
Imports System.Data.SqlClient
Imports Microsoft

Namespace TESTING
Public Class Test
Inherits System.Web.UI.Page
Public Function CheckSubmitFlags(id as string) As SqlDataReader

Dim MyConn As SqlConnection = New SqlConnection("Password=benq;Persist
Security Info=True;User ID=mytime;Initial Catalog=MyTime;Data
Source=ERIE\RSIINTERNAL")
Dim cmd As New SqlCommand("SP_Test", MyConn)
cmd.CommandType = CommandType.StoredProcedure

Dim empID As SqlParameter = cmd.Parameters.Add("@id",
SqlDbType.VarChar, 50)
empID.Value = ID
empID.Direction = ParameterDirection.Input

Dim empName As SqlParameter = cmd.Parameters.Add("@supname",
SqlDbType.VarChar, 50)
empName.Direction = ParameterDirection.Output
MyConn.Open()
Dim result As SqlDataReader = cmd.ExecuteReader()
Return result
End Function

End Class
End Namespace

============================================================
Could you please let me know how to read the out put parameter
returned from a function from a on page_load event on client side. THX
GUYS.
 
K

Kevin Spencer

You won't be able to access any output parameters until you close the
DataReader.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
R

Rick Spiewak

response.write(dr.item(2)), or if you know the name of the item you can use
dr.item("name")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top