By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,652 Members | 1,010 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,652 IT Pros & Developers. It's quick & easy.

display data in stored procedure from multiple tables in label con

P: n/a
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.
Apr 18 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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" <th****@community.nospam> wrote in message
news:87**********************************@microsof t.com...
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.

Apr 18 '06 #2

P: n/a
Hey Josh, using the ordinal did the trick. I appreciate your help!

"Josh" wrote:
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" <th****@community.nospam> wrote in message
news:87**********************************@microsof t.com...
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.


Apr 18 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.