Dataset alternative to stored proc row results

A

Al

Using the reader object I'm not having a problem retrieving stored
procedure return values, but I'm having trouble getting at the actual
data coming back in the row results. My first impulse would be to fill
a dataset, but I'd prefer to return the results in a more generic
fashion, hopefully via the reader. Again, these are row results coming
back from a proc, so there won't be any named variables to work with.
Any suggestions?

Thanks in advance,
Al
 
P

Patrice

Humm... Using GetOrdinal maybe ?

Else please elaborate a bit about what you meant by "I'm having trouble
getting at the actual data coming back in the row results"...
 
A

Al

Thanks Patrice. Let's say this is the stored proc:

create procedure bogus
as
select last_name from people where first_name = "Al"
return 0

What I'm after is the row result, e.g., "Smith" as opposed to the
return value ("0" in this case). Here's what I'm doing:

SqlCommand myCommand =
GetConnection(sqlConnectionString,"bogus");
SqlDataReader myReader = myCommand.ExecuteReader();
while(myReader.Read())
{
stringResult = myReader.GetString(0);
}
myReader.Close();
---------------------------

In this case, "0" is returned instead of "Smith" - how do I get at
"Smith?"

Thanks,
Al
 
A

Al

WOOPS - my aplogies to anyone that applied any brain power to this
quandry - turns out my web service was pointing at a different server
than what I was running raw SQL against. So, a simple
myReader.GetSqlString(0).ToString() did the trick for me.

Thanks anyway,
Al
 

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