Friday, August 14, 2009

Retrieving Data Using the DataReader C# Asp.net

void loaddata()
{
SqlConnection myConnection = new SqlConnection(ConnectionString);
char stus = "N";
string strSQL = "select * FROM sATINOUT WHERE PNEMPID=" + Session["Udid"] + " and PNSTUS=" + stus;
SqlCommand cmd = new SqlCommand(strSQL, myConnection);
myConnection.Open();
SqlDataReader myReader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
if (myReader.HasRows)
{
while (myReader.Read())
{
TxtUSERid.Text = myReader["UDUSRID"].ToString();
txtpasswd.Text = myReader["UDPASSWD"].ToString();
}
}
myReader.Close();
myConnection.Close();
}


Retrieving Data Using the DataReader

No comments: