473,804 Members | 3,126 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:

---------------------------------------------------------------------------------------------------------------------------------
ConnectionStrin gSettings connectionSetti ngs =
ConfigurationMa nager.Connectio nStrings["ConnectionStri ng"];

SqlDataSource ds = new SqlDataSource() ;

ds.SelectComman dType = SqlDataSourceCo mmandType.Store dProcedure;
ds.SelectComman d = "GetCustomerNam e";

ds.SelectParame ters.Add("trade rId", 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 3495
Will this of any help?
http://msdn2.microsoft.com/en-us/library/37hwc7kt.aspx

"Dave" <bu****@wizardb uy.comwrote in message
news:11******** **************@ 74g2000cwt.goog legroups.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:

---------------------------------------------------------------------------------------------------------------------------------
ConnectionStrin gSettings connectionSetti ngs =
ConfigurationMa nager.Connectio nStrings["ConnectionStri ng"];

SqlDataSource ds = new SqlDataSource() ;

ds.SelectComman dType = SqlDataSourceCo mmandType.Store dProcedure;
ds.SelectComman d = "GetCustomerNam e";

ds.SelectParame ters.Add("trade rId", 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 ConnectionStrin g, SelectCommand (&
SelectParameter s if required) and call the Select method. Assuming
SqlDataSource.D ataSourceMode is set DataSet, returnedDataVie w[0][0] should
give the first column of the first row from the stored proc.

DataView returnedDataVie w= (DataView)ds.Se lect();

Is this what your looking for?

"Dave" <bu****@wizardb uy.comwrote in message
news:11******** **************@ b28g2000cwb.goo glegroups.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
1411
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" SelectCommand="SELECT Top 1 LastName,Name FROM mytable where ......"></asp:SqlDataSource>
3
11287
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: <asp:SqlDataSource ID="DataSource1" runat="server" ConnectionString="<%$ ConnectionStrings: ConnectionString1 %>" SelectCommand="UserLkp" SelectCommandType="StoredProcedure"
6
8276
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 trying to load the ddl with a list of dates from another table keyed on GridView row field that only apply to this row. Any suggestions would be appreciated.
0
1603
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 only with the master_id for the status table's current status. After having some trouble databinding I found a solution using a hidden label to save the value I need for my select parameter. The error I am receiving is 'ddlStatus' has a...
2
4265
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 column (which means it appears for every record returned). I already have a way of determining how many rows were returned, and use that information in a label to say "Your search has returned x records" at the top of the page, above the gridview...
4
7255
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...
0
4634
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 can get the datakey we need Button btnDetails = sender as Button; GridViewRow row = (GridViewRow)btnDetails.NamingContainer; DropDownList ddl = ((DropDownList)dvVehicleDetail.FindControl("DropdownList1"));
3
2320
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 bind to any control, cookie or something like this. How do I set a value for this parameter before calling the SQLDataSource1.Delete() method?
4
2909
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 is not a null value. I am not using any code behind (C#) to bind the data or manipulate the data. I have read that when there is a null value in the database that there is no record in the "dataset". Can anyone show me how to bind a value in the...
0
9705
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9575
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
10320
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10308
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
9134
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6846
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();...
0
5513
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4288
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
3
2981
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.