473,383 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

get an output value from a stored procedure using sqlDataSource

I am trying to get an output value from a stored procedure using
sqlDataSource in asp.net 2.0. But I only get a null value for the
output. Can someone please help?
The sqlDataSource:

<asp:SqlDataSource ID="DataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings: ConnectionString1 %>"
SelectCommand="UserLkp" SelectCommandType="StoredProcedure"

<SelectParameters>
<asp:Parameter Name="UserID" Type="String" />
<asp:Parameter Direction="InputOutput" Name="Role" Type="String" />
</SelectParameters>
</asp:SqlDataSource>

My stored Procedure is

CREATE PROCEDURE [dbo].[UserLkp]
@Hawkid varchar(30),
@eRole varchar(50) OUTPUT
as
select @eRole=eRole from eUsers Where eUser=@Hawkid
GO

I am using selected event of dataSource1 as in the following:

Protected Sub DataSource1_Selected(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.SqlDataSourceStatusEvent Args) Handles
eUserDataSource.Selected

Dim param As System.Data.SqlClient.SqlParameter
For Each param In e.Command.Parameters
Response.Write(Server.HtmlEncode(param.ParameterNa me) &
"=")
Response.Write(Server.HtmlEncode(param.Value) & " (")
Response.Write(Server.HtmlEncode(param.Value.GetTy pe().ToString()) &
")<br />")
Next

End Sub

Feb 9 '06 #1
3 11263
use sql profiler to see what parameter value is passed for @Hawkid.

-- bruce (sqlwork.com)
"michelle" <ro*****@yahoo.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
I am trying to get an output value from a stored procedure using
sqlDataSource in asp.net 2.0. But I only get a null value for the
output. Can someone please help?
The sqlDataSource:

<asp:SqlDataSource ID="DataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings: ConnectionString1 %>"
SelectCommand="UserLkp" SelectCommandType="StoredProcedure"

<SelectParameters>
<asp:Parameter Name="UserID" Type="String" />
<asp:Parameter Direction="InputOutput" Name="Role" Type="String" />
</SelectParameters>
</asp:SqlDataSource>

My stored Procedure is

CREATE PROCEDURE [dbo].[UserLkp]
@Hawkid varchar(30),
@eRole varchar(50) OUTPUT
as
select @eRole=eRole from eUsers Where eUser=@Hawkid
GO

I am using selected event of dataSource1 as in the following:

Protected Sub DataSource1_Selected(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.SqlDataSourceStatusEvent Args) Handles
eUserDataSource.Selected

Dim param As System.Data.SqlClient.SqlParameter
For Each param In e.Command.Parameters
Response.Write(Server.HtmlEncode(param.ParameterNa me) &
"=")
Response.Write(Server.HtmlEncode(param.Value) & " (")
Response.Write(Server.HtmlEncode(param.Value.GetTy pe().ToString()) &
")<br />")
Next

End Sub

Feb 10 '06 #2
Hi Bruce,

I took out the input parameter and gave it a value, it still does not
work.

CREATE PROCEDURE [dbo].[UserLkp]
@eRole varchar(50) OUTPUT
as
select @eRole=eRole from eUsers Where eUser=eee'
GO

Feb 10 '06 #3

Change your parameter name into "eRole" and try again.

<asp:Parameter Direction="InputOutput" Name="eRole" Type="String" />
************************************************** **************
Tapio Kulmala

"Those are my principles. If you don't like them I have others."

- Groucho Marx
************************************************** **************


The sqlDataSource:

<asp:SqlDataSource ID="DataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings: ConnectionString1 %>"
SelectCommand="UserLkp" SelectCommandType="StoredProcedure"

<SelectParameters>
<asp:Parameter Name="UserID" Type="String" />
<asp:Parameter Direction="InputOutput" Name="Role" Type="String" />
</SelectParameters>
</asp:SqlDataSource>

My stored Procedure is

CREATE PROCEDURE [dbo].[UserLkp]
@Hawkid varchar(30),
@eRole varchar(50) OUTPUT
as
select @eRole=eRole from eUsers Where eUser=@Hawkid
GO


Feb 14 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Steve Holden | last post by:
Has anyone, with any driver whatsoever, managed to retrieve output parameters from a SQL Server stored procedure? I've just been rather embarrassed to find out it's not as easy as it might seem,...
4
by: laurenq uantrell | last post by:
I need to get the value of an output parameter back into my VBA function calling a stored procedure. I'm using the following construction to append a new record in a SQL Server table: ...
1
by: jkeel | last post by:
If I try to Update a record with the following code using a stored procedure I get an error: <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$...
0
by: Brew | last post by:
Hello, I'm writing an ASP.NET 2005 (VB) Website with an Oracle 9i backend I have an oracle package with stored procedures and functions I need to use from the VB Code, I'm trying to use the...
0
by: Kieran | last post by:
Hello, I am trying to use a GridView nested within a repeater to group items together. To do this I would like to use the output of the repeater control (int_pk_parent_definition_id) to be the...
4
by: =?Utf-8?B?QmFidU1hbg==?= | last post by:
Hi, I have a GridView and a SqlDataSource controls on a page. The SqlDataSource object uses stored procedures to do the CRUD operations. The DataSource has three columns one of which -...
1
by: Ted | last post by:
Here is a stored procedure I created in MySQL: CREATE PROCEDURE `sp_find_food`( IN search_string varchar(255) ) BEGIN DECLARE ss VARCHAR(257); SET ss = CONCAT('%',search_string,'%'); SELECT...
1
by: John Bailo | last post by:
This is a my solution to getting an Output parameter from a SqlDataSource. I have seen a few scant articles but none of them take it all the way to a solution. Hopefully this will help some...
5
by: CyberSoftHari | last post by:
I am trying to get an output Parameters value from a stored procedure using sqlDataSource in asp.net 2.0. But I only get a null value for the output Parameters. Can someone Point me to get value? ...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.