SQLClient output parameters - Regular SELECT?

G

Guest

Hi all,

Can ADO.NET SQL client output parmaeters be used with a regular select
statement?

If they can, does anyone have a quick example (and select statement) so how
how to do this?

Thanks.
 
M

Marina

May I ask why you would want to do this? Why not just select just everything
you need directly as columns.
 
B

Bruce Barker

no. you can put the select in a proc, and call it.

create procedure foo
@id int,
@a varchar(max) out,
@b varchar(max) out
as
select @a = a, @b = b
from foo where id = @id
if @@rowcount > 0
return 0 -- ok
return -1 -- failed


now you can call the proc and get the selected columns values as parameters

-- bruce (sqlwork.com)
 
G

Guest

May I ask why you would want to do this? Why not just select just
everything you need directly as columns.

I wanted to avoid using a dataset or datareader to extract a couple
parameters.

i.e. I only want the Username for UserID = 5. Or I'm only interested in the
Description of ProductID 15. etc etc.

Any ideas?
 
M

Marina

You can use ExecuteScalar to get one piece of information out.

However, I still don't really see why using a datareader is any harder then
pulling parameter values out if you need several pieces of information.
 
G

Guest

You can use ExecuteScalar to get one piece of information out.

Can executescalar return non-integer values?
However, I still don't really see why using a datareader is any harder
then pulling parameter values out if you need several pieces of
information.

A lot of times, I only need one piece ; ) But when I need multiple pieces
of info, I don't mind using a datareader or dataset.
 

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

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top