473,664 Members | 2,972 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:SqlDataSou rce ID="DataSource1 " runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs: ConnectionStrin g1 %>"
SelectCommand=" UserLkp" SelectCommandTy pe="StoredProce dure"

<SelectParamete rs>
<asp:Paramete r Name="UserID" Type="String" />
<asp:Paramete r Direction="Inpu tOutput" Name="Role" Type="String" />
</SelectParameter s>
</asp:SqlDataSour ce>

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_Sel ected(ByVal sender As Object, ByVal e As
System.Web.UI.W ebControls.SqlD ataSourceStatus EventArgs) Handles
eUserDataSource .Selected

Dim param As System.Data.Sql Client.SqlParam eter
For Each param In e.Command.Param eters
Response.Write( Server.HtmlEnco de(param.Parame terName) &
"=")
Response.Write( Server.HtmlEnco de(param.Value) & " (")
Response.Write( Server.HtmlEnco de(param.Value. GetType().ToStr ing()) &
")<br />")
Next

End Sub

Feb 9 '06 #1
3 11279
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.goo glegroups.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:SqlDataSou rce ID="DataSource1 " runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs: ConnectionStrin g1 %>"
SelectCommand=" UserLkp" SelectCommandTy pe="StoredProce dure"

<SelectParamete rs>
<asp:Paramete r Name="UserID" Type="String" />
<asp:Paramete r Direction="Inpu tOutput" Name="Role" Type="String" />
</SelectParameter s>
</asp:SqlDataSour ce>

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_Sel ected(ByVal sender As Object, ByVal e As
System.Web.UI.W ebControls.SqlD ataSourceStatus EventArgs) Handles
eUserDataSource .Selected

Dim param As System.Data.Sql Client.SqlParam eter
For Each param In e.Command.Param eters
Response.Write( Server.HtmlEnco de(param.Parame terName) &
"=")
Response.Write( Server.HtmlEnco de(param.Value) & " (")
Response.Write( Server.HtmlEnco de(param.Value. GetType().ToStr ing()) &
")<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:Paramete r Direction="Inpu tOutput" Name="eRole" Type="String" />
*************** *************** *************** *************** ****
Tapio Kulmala

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

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


The sqlDataSource:

<asp:SqlDataSou rce ID="DataSource1 " runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs: ConnectionStrin g1 %>"
SelectCommand=" UserLkp" SelectCommandTy pe="StoredProce dure"

<SelectParamete rs>
<asp:Paramete r Name="UserID" Type="String" />
<asp:Paramete r Direction="Inpu tOutput" Name="Role" Type="String" />
</SelectParameter s>
</asp:SqlDataSour ce>

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
8280
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, and people are saying bad things about Python as a result :-( mx.ODBC, which I regard as a highly-capable module, does not support the callproc() API, and suggests use of the ODBC call format. It has caveats in (some of) the documentation...
4
45102
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: Function ThisFunctionInsertsANewRecord() On Error GoTo myErr Dim cmd As ADODB.Command
1
2633
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="<%$ ConnectionStrings:stellentConnectionString %>" SelectCommand="spWC_Adjusters" SelectCommandType="StoredProcedure" InsertCommand="spWC_Adjusters_Insert " InsertCommandType="StoredProcedure" UpdateCommand="spWC_Adjusters_Update"
0
2249
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 SQLDataSource to call a stored procedure passing parameters and then displaying the results on a GridView control my trouble is with the parameters and displaying results into the GridView.
0
2275
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 SQL parameter for the stored procedure which is the datasource for the GridView. Any ideas? Help would be much appreciated. I've included what I've done so far below but it doesn't work because
4
7239
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 - "Modified" of type DateTime - is hidden since it should not be edited by a user. The system handles the update for this column. So, I have hidden (Visible=false) this column on the grid. In order to access the value in this field, I have created a...
1
2291
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 NDB_No,Long_Desc FROM food_des WHERE Long_Desc LIKE ss; END
1
12303
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 poor soul. Situation: I want to do a lookup using a stored procedure for each value in a Row within a GridView. I use a lookup function in my code behind, evaluating the necessary bound fields. The problem is the SqlDataSource representing...
5
2617
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? SqlDataSource InsertDS = getSqlDataSource; //-----------------parameters InsertDS.InsertParameters.Add("FirstName", FirstName); ....................................... //----------------This is an Output Param
0
8348
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8861
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8549
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8636
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6187
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5660
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2764
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2003
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1759
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.