This code for show each values that you select many record
from sql server.
please see code below:
string str="select Name form tblName where ID between 1 and 5";
Sqlcommand cmd=new Sqlcommand(str,connection);
DataReader Dreader=cmd.ExecuteReader();
While (Dreader.Read())
{
if (DReader["ID"].ToString().Equals("1")) txtName1.Text = DReader["Name"].ToString();
if (DReader["ID"].ToString().Equals("2")) txtName2.Text = DReader["Name"].ToString();
if (DReader["ID"].ToString().Equals("3")) txtName3.Text = DReader["Name"].ToString();
if (DReader["ID"].ToString().Equals("4")) txtName4.Text = DReader["Name"].ToString();
if (DReader["ID"].ToString().Equals("5")) txtName5.Text = DReader["Name"].ToString();
}
Dreader.Close();
No comments:
Post a Comment