473,398 Members | 2,404 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,398 software developers and data experts.

Get a single value from SQLDataSource

Hi

I am using .NET 2 with c# and want to retrieve a single value from my
stored procedure.

I currently have the following code:

---------------------------------------------------------------------------------------------------------------------------------
ConnectionStringSettings connectionSettings =
ConfigurationManager.ConnectionStrings["ConnectionString"];

SqlDataSource ds = new SqlDataSource();

ds.SelectCommandType = SqlDataSourceCommandType.StoredProcedure;
ds.SelectCommand = "GetCustomerName";

ds.SelectParameters.Add("traderId", TypeCode.Int32, "1");

ds.Select();
---------------------------------------------------------------------------------------------------------------------------------

Obviously this won't get my customer name :(

How do I get the actual value?

Thanks!

Aug 13 '06 #1
3 3467
Will this of any help?
http://msdn2.microsoft.com/en-us/library/37hwc7kt.aspx

"Dave" <bu****@wizardbuy.comwrote in message
news:11**********************@74g2000cwt.googlegro ups.com...
Hi

I am using .NET 2 with c# and want to retrieve a single value from my
stored procedure.

I currently have the following code:

---------------------------------------------------------------------------------------------------------------------------------
ConnectionStringSettings connectionSettings =
ConfigurationManager.ConnectionStrings["ConnectionString"];

SqlDataSource ds = new SqlDataSource();

ds.SelectCommandType = SqlDataSourceCommandType.StoredProcedure;
ds.SelectCommand = "GetCustomerName";

ds.SelectParameters.Add("traderId", TypeCode.Int32, "1");

ds.Select();
---------------------------------------------------------------------------------------------------------------------------------

Obviously this won't get my customer name :(

How do I get the actual value?

Thanks!

Aug 13 '06 #2
Yeah that is how I have always done it.

Just curious if it can be done with the SQLDataSource?

Aug 13 '06 #3
Yes. Set the SqlDataSource's ConnectionString, SelectCommand (&
SelectParameters if required) and call the Select method. Assuming
SqlDataSource.DataSourceMode is set DataSet, returnedDataView[0][0] should
give the first column of the first row from the stored proc.

DataView returnedDataView= (DataView)ds.Select();

Is this what your looking for?

"Dave" <bu****@wizardbuy.comwrote in message
news:11**********************@b28g2000cwb.googlegr oups.com...
Yeah that is how I have always done it.

Just curious if it can be done with the SQLDataSource?

Aug 13 '06 #4

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

Similar topics

0
by: Xavier | last post by:
hello, how can i display the returned value of a SqlDataSource in a Label <asp:SqlDataSource ConnectionString="<%$ ConnectionStrings:Pubs %>" ID="SqlDataSource1" runat="server"...
3
by: michelle | last post by:
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: ...
6
by: Dabbler | last post by:
I have a dropdownlist in a GridView ItemTemplate. I need to bind the ddl to an SqlDataSource, then have a value from a boundfield in the row be passed as the keyfield for select where clause. Im...
0
by: Managed Code | last post by:
Hello, I have a status and definition table. The status table's current status field relates the ID field of the definition table. I am trying to retrieve the definitions that are associated...
2
by: Mike | last post by:
I have a SqlDataSource that returns a list of companies and their details by ProductID from a stored procedure. It also returns the name of the product associated with the ProductID as the final...
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 -...
0
by: dayiku | last post by:
I am trying to retrieve values from a boundfield in a detailsview. protected void BtnViewDetails_Click(object sender, EventArgs e) { // get the gridviewrow from the sender so we...
3
by: Roger Jordan | last post by:
Hello, I'm using a SQLDataSource with name SqlDataSource1, the DeleteCommand has a parameter, with isdefined in SqlDataSource.DeleteParameter: DELETE FROM WHERE =@ID The parameter is not...
4
by: justice750 | last post by:
Hi All, I am using a FormView control. The allows me to update records in the database. However, when a database field is null I can not update the field on the form. It works fine when the field...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.