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.SqlDataSourceStatusEventArgs) Handles
eUserDataSource.Selected
Dim param As System.Data.SqlClient.SqlParameter
For Each param In e.Command.Parameters
Response.Write(Server.HtmlEncode(param.ParameterName) &
"=")
Response.Write(Server.HtmlEncode(param.Value) & " (")
Response.Write(Server.HtmlEncode(param.Value.GetType().ToString()) &
")<br />")
Next
End Sub
Bruce Barker - 10 Feb 2006 00:30 GMT
use sql profiler to see what parameter value is passed for @Hawkid.
-- bruce (sqlwork.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
[quoted text clipped - 38 lines]
>
> End Sub
michelle - 10 Feb 2006 16:02 GMT
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
Tapio Kulmala - 14 Feb 2006 14:31 GMT
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:
>
[quoted text clipped - 16 lines]
> select @eRole=eRole from eUsers Where eUser=@Hawkid
> GO