1
public partial class _EditEmp : System.Web.UI.Page
    {
        string connStr = WebConfigurationManager.ConnectionStrings["Econn"].ConnectionString;
        OleDbConnection conn;

        protected void Page_Load(object sender, Event,Args e)
        {
            if (!IsPostBack)
            {
                if (!string.IsNullOrEmpty(Context.Request.QueryString["EMP_ID"]))
                {
                    EMP_ID.Value = Context.Request.QueryString["EMP_ID"];
                    LEMP_ID.Text = EMP_ID.Value;
                    conn = new OleDbConnection(connStr);
                    conn.Open();
                    OleDbCommand myCommand = new OleDbCommand("SELECT * FROM EMP WHERE EMP_ID=@EMP_ID", conn);
                    myCommand.CommandType = CommandType.Text;
                    OleDbParameter PEMP_ID = new OleDbParameter("@EMP_ID", OleDbType.VarChar);
                    PEMP_ID.Value = Context.Request.QueryString["EMP_ID"];
                     myCommand.Parameters.Add(PEMP_ID);
                    OleDbDataReader DRName = myCommand.ExecuteReader();
                    if (DRName.Read() == true)
                    {
                        LEMP_ID.Text = DRName["EMP_ID"].ToString();
                        txt_FN.Text = DRName["FIRST_NAME"].ToString();
                        txt_LN.Text = DRName["LAST_NAME"].ToString();
                        txt_DOB.Text = DRName["DOB"].ToString();
                        txt_address.Text = DRName["ADDRESS"].ToString();
                        txt_pn.Text = DRName["PHONE_NO"].ToString();
                        txt_email.Text = DRName["EMAIL"].ToString();
                        }
                    DRName.Close();
                    conn.Close();

            } } }}}
4

0 回答 0