display data in stored procedure from multiple tables in label con

G

Guest

I have a DBA that wrote a stored procedure that does a SELECT from a
particluar SQL Server table. Within that stored procedure he links over to
grab a column from another database table. I need to display this information
in 5 different label controls in an ASP.NET web page. When I test the stored
procedure in a GridView all the columns display correctly (I am not manually
defining the columns). When I try to use labels I can display all this
information fine with the exception of the column that he calls from the
separate table. I'm getting an "IndexOutOfRangeException- Make sure your
column names are correct". I've tried naming the column in my code the same
thing he uses in his stored procedure as well as the automatically generated
column name that I see in the GridView when I test it. Nothing seems to work.
Can someone help me with the correct syntax to call this column?

Here is the code snipet for rendering the labels in the ASP.NET page.
"uxMemberParticipation.Text += reader["Column1"].ToString();" is the line in
question that keeps erroring out.

while (reader.Read())
{
uxCertNumber.Text += reader["CertNbr"].ToString();
uxLastName.Text += reader["LName"].ToString();
uxFirstName.Text += reader["FName"].ToString();
uxStatusDate.Text += reader["StatusDate"].ToString();
uxMemberParticipation.Text += reader["Column1"].ToString();
}

My DBA's stored procedure snipet is below. The
dbo.MemberParticipation(CoverageCode) is where he is calling the other table.
I've tried every combination of that line in my label and nothing seems to
work:

BEGIN --Member Found
SELECT CertNbr, LName, FName, StatusDate,
dbo.MemberParticipation(CoverageCode)
FROM tbMember
WHERE MemberID = @sMemberIDAND DependentNbr = '00' AND
LName=@sLastName AND MemberStatus <>'T'
RETURN
END

I apologize for the long post but any help would be appreciated.
 
J

Josh

I'd suggest changing the stored proc so that is allocates an alias to the
additional column. I suspect the column has no name.

You might also try referencing the column by ordinal, that is ,its column
number , reader[4].ToString();
 
G

Guest

Hey Josh, using the ordinal did the trick. I appreciate your help!

Josh said:
I'd suggest changing the stored proc so that is allocates an alias to the
additional column. I suspect the column has no name.

You might also try referencing the column by ordinal, that is ,its column
number , reader[4].ToString();

--
#####-----#####-----#####
POV Tips and Hints at ...
http://povman.blogspot.com/
Joe Campbell said:
I have a DBA that wrote a stored procedure that does a SELECT from a
particluar SQL Server table. Within that stored procedure he links over to
grab a column from another database table. I need to display this
information
in 5 different label controls in an ASP.NET web page. When I test the
stored
procedure in a GridView all the columns display correctly (I am not
manually
defining the columns). When I try to use labels I can display all this
information fine with the exception of the column that he calls from the
separate table. I'm getting an "IndexOutOfRangeException- Make sure your
column names are correct". I've tried naming the column in my code the
same
thing he uses in his stored procedure as well as the automatically
generated
column name that I see in the GridView when I test it. Nothing seems to
work.
Can someone help me with the correct syntax to call this column?

Here is the code snipet for rendering the labels in the ASP.NET page.
"uxMemberParticipation.Text += reader["Column1"].ToString();" is the line
in
question that keeps erroring out.

while (reader.Read())
{
uxCertNumber.Text += reader["CertNbr"].ToString();
uxLastName.Text += reader["LName"].ToString();
uxFirstName.Text += reader["FName"].ToString();
uxStatusDate.Text += reader["StatusDate"].ToString();
uxMemberParticipation.Text += reader["Column1"].ToString();
}

My DBA's stored procedure snipet is below. The
dbo.MemberParticipation(CoverageCode) is where he is calling the other
table.
I've tried every combination of that line in my label and nothing seems to
work:

BEGIN --Member Found
SELECT CertNbr, LName, FName, StatusDate,
dbo.MemberParticipation(CoverageCode)
FROM tbMember
WHERE MemberID = @sMemberIDAND DependentNbr = '00' AND
LName=@sLastName AND MemberStatus <>'T'
RETURN
END

I apologize for the long post but any help would be appreciated.
 

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