Forum Moderators: open

Message Too Old, No Replies

DataReader to Label

         

jwbradshaw

1:45 pm on May 26, 2009 (gmt 0)

10+ Year Member



Hello all! I'm having trouble remembering how to have the results of a datareader bound to a label. I've been doing some searching on the internet and I can't seem to find the right answer. Here's the code I'm using right now. I know the bold area is where i'm having trouble.

In addition, should I be using a DataGrid instead of a DataReader in this case?

private void LoadManualUsage()
{
SqlConnection conn = new SqlConnection(
"connection details here");
SqlCommand comm = new SqlCommand(
"Select column1, column2, column3, column4 * From someTable where processStatus = 1", conn);
SqlDataReader reader;
try
{
conn.Open();
reader = comm.ExecuteReader();
while (reader.Read())
LDCUsageLabel.Text += reader.();

reader.Close();
}
catch
{
Response.Write("Error gathering table data.");
}
finally
{
conn.Close();

}
}

jwbradshaw

4:00 pm on May 27, 2009 (gmt 0)

10+ Year Member



nevermind, i figured out what i need and decided to use a repeater control.