Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / February 2006

Tip: Looking for answers? Try searching our database.

get an output value from a stored procedure using sqlDataSource

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
michelle - 09 Feb 2006 21:13 GMT
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



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.