Get a single value from SQLDataSource

D

Dave

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!
 
S

Siva M

Will this of any help?
http://msdn2.microsoft.com/en-us/library/37hwc7kt.aspx

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!
 
D

Dave

Yeah that is how I have always done it.

Just curious if it can be done with the SQLDataSource?
 
S

Siva M

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?

Yeah that is how I have always done it.

Just curious if it can be done with the SQLDataSource?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top