private void registerAccount(account a) { account Account = new account(); Account.name = a.name; Account.password = a.password; Account.email_address = a.email_address; Account.contact_number = a.contact_number; Account.activation_code = a.activation_code; using (ecommerceEntities db = new ecommerceEntities()) { db.accounts.Add(Account); db.SaveChanges(); sendCode(); //Response.Redirect("WebForm2.aspx?email_address="+txtEmail.Text); } }
protected void Button2_Click(object sender, EventArgs e) { account A = new account(); Random random = new Random(); activationcode = random.Next(1001, 9999).ToString(); A.name = txtName.Text; A.password = txtConfirmpassword.Text; A.email_address = txtEmail.Text; A.activation_code = "Unregistered"; registerAccount(A); using (SqlConnection con = new SqlConnection(CS)) { string myquery = "select *from account where email_address='" + Request.QueryString["txtEmail"] + "'"; con.Open(); SqlCommand cmd = new SqlCommand(); cmd.CommandText = myquery; cmd.Connection = con; SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = cmd; DataSet ds = new DataSet(); da.Fill(ds); if (ds.Tables[0].Rows.Count > 0) { string activationcode; activationcode = ds.Tables[0].Rows[0]["activationcode"].ToString(); if (activationcode == Request["code"]) { changeStatus(); } } else { } } }