Good day
I have the following table:
ID Paragraph
1 Peter is walking in the garden.
2 Jackes is playing with the ball.
I want to display the two records(Paragraphs) on seperate labels. I have used Idatareader to read the values from the table.
My problem is, it's displaying only the last record("Jackes is playing with the ball") on both lables. I want to display "Peter is walking in the garden" on label1 and "Jackes is playing with the ball" on label2, or vice versa.
What is wrong with the code?
Here is my code
//Method inside a class
public IDataReader Showrecentnews()
{
IDataReader reader = null;
SqlDatabase sqldb = new SqlDatabase(clsTsogoSafe.Instance.connectionstring);
reader = sqldb.ExecuteReader("PSELRECENTNEWS", new object[] { });
return reader;
}
//Calling the method in my main unit
protected void Button1_Click(object sender, EventArgs e)
{
clsDBCalls objDBcalls = new clsDBCalls();
IDataReader reader = objDBcalls.Showrecentnews();
while (reader.Read())
{
Label1.Text = reader["Paragraph"].ToString();
Label2.Text = reader["Paragraph"].ToString();
}
reader.NextResult();
}
Thanks