Stored Procedure return values

G

George

Hi, I have a stored procedure that return 2 values (not 2 rows). Two
separate values. How can I read both of them from a Sql Command Object in
C#. When I execute the command and assign the results in a data reader I
have only one index at the data reader. Like the second value has never been
read.

What can I do?
 
N

Norman Yuan

If you do not show your SP code and your C# code of how the SP is called, it
is hard to say what is wrong, but it is certain to say you did something
wrong.
 
S

sloan

http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!176.entry


Below is the basic syntax/snipplet. If you're having trouble, full
downloadable example (which uses the Northwind database) is above.


while (dataReader1.Read())
{
if (!(dataReader1.IsDBNull(0)))
{

if (!(dataReader1.IsDBNull(0)))
{
string companyName = dataReader1.GetString(0);
}



if (!(dataReader1.IsDBNull(1)))
{
string city = dataReader1.GetString(1);
}


}
}
 
K

Kenny

Search the Internet for info on Output parameters ... maybe that's what
you're looking for?
 

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

Top