Code Behind Help

Discussion in 'General Computer Support' started by marsha27e, Feb 20, 2011.

  1. marsha27e

    marsha27e

    Joined:
    Feb 20, 2011
    Messages:
    1
    I keep getting this error when I try to debug my web site using visual studio 2010

    An exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll but was not handled in user code
    A first chance exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll

    Here is the code;

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data;
    using System.Data.OleDb;
    using System.Data.SqlClient;

    public partial class NewAccount : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
    //lets check the db for this user name
    //Submit user data to db.
    user usr = new user();
    database db = new database();

    usr.EmailAddress = txtEmailAddress.Text;
    usr.FirstName = txtFirstName.Text;
    usr.LastName = txtLastName.Text;
    usr.Password = txtPasswordVer.Value;

    String insertSQL = "INSERT INTO USERS (FIRSTNAME,LASTNAME,EMAILADDRESS,PASSWORD) VALUES ("
    + "'" + usr.FirstName + "','" + usr.LastName + "','" + usr.EmailAddress + "','" + usr.Password + "')";

    if (db.dbInsert(insertSQL) == true)
    {
    string querySQL = "Select ID FROM USERS WHERE EMAILADDRESS='" + usr.EmailAddress + "'";
    SqlDataReader oDR = db.dbQuery(querySQL);

    if (oDR.HasRows)
    {
    oDR.Read();

    //get value from db
    usr.UserID = Convert.ToInt32(oDR.GetValue(oDR.GetOrdinal("ID")));
    }

    //Redirect
    HttpCookie cookie = Request.Cookies["WSCUser"];
    if (cookie == null)
    {
    cookie = new HttpCookie("WSCUser");
    }

    cookie["User"] = usr.EmailAddress;
    cookie["FName"] = usr.FirstName;
    cookie["ID"] = usr.UserID.ToString();
    //cookie["ROLEID"] = usr.RoleID.ToString();

    cookie.Expires = DateTime.Now.AddMinutes(30);
    Response.Cookies.Add(cookie);
    Response.Redirect("~\\CustomerInterface.aspx");
    }

    //create SMTP instance
    //SMTP sendNewUserMail = new SMTP();

    //build email body
    //String newuserEmailBody = usr.FirstName.ToString() + " Welcome to Williams Specialty Company. Use the following login to access the site and it's contents. " +
    // "Username: " + usr.EmailAddress + " Password: " + usr.Password + " If you have any problems please email admin@adelphia.us.com.";

    //build email body for admin
    //String newuserEmailBodyAdmin = "Username: " + usr.EmailAddress;

    //send new user an email
    //sendNewUserMail.SendMail("admin@adelphia.us.com", usr.EmailAddress, "NEW USER CONFIRMATION", newuserEmailBody);

    //send Admin email
    //sendNewUserMail.SendMail("admin@wsc.com", "admin@wsc.com", "NEW USER NOTIFICATION", newuserEmailBodyAdmin);


    }
    protected void Button2_Click(object sender, EventArgs e)
    {
    //user selected cancel
    //popup box, are you sure?
    txtEmailAddress.Text = "";
    txtFirstName.Text = "";
    txtLastName.Text = "";
    txtPasswordVer.Value = "";

    //if yes, back to home page
    //if no, back to new account setup page
    }
    private void loginUser(String username, String password)
    {
    //Build query string for determining if the user already exists
    String ValidateUserQueryString = "SELECT username FROM userlist WHERE username='" + username + "'";

    //Instantiate the DB Object Class File
    database db = new database();

    //Query DB for user
    SqlDataReader oDR = db.dbQuery(ValidateUserQueryString);

    if (oDR.HasRows)
    {
    oDR.Read();

    //get value from db
    String un = oDR.GetValue(oDR.GetOrdinal("username")).ToString();
    if (username != un)
    {
    //loginLabel.Text = "User Not Found, Would you like to Register?";
    //hlinkRegisterNewUser.Visible = true;
    return;
    }
    else
    {
    //validatePassword(username, password);
    }
    }
    else
    {
    //loginlabel.Text = "User Not Found, Would you like to Register?";
    //hlinkRegisterNewUser.Visible = true;
    return;
    }

    }
    //private void validatePassword(String userID, String password)
    //{
    // String ValidatePasswordQueryString = "SELECT pword FROM userlist WHERE username ='" + userID + "'";
    // databaseObject objDB = new databaseObject();
    // OleDbDataReader oDR = objDB.dbQuery(ValidatePasswordQueryString);

    // if (oDR.HasRows)
    // {
    // oDR.Read();

    // //get value from db
    // String pw = oDR.GetValue(oDR.GetOrdinal("pword")).ToString();
    // if (pw != password)
    // {
    // loginlabel.Text = "Invalid Username/Password";
    // txtPassword.Focus();
    // return;
    // }
    // else
    // {
    // Response.Cookies["userName"].Value = userID;
    // Response.Cookies["userName"].Expires = DateTime.Now.AddDays(1);

    // //HttpCookie aCookie = new HttpCookie("lastVisit");
    // //aCookie.Value = DateTime.Now.ToString();
    // //aCookie.Expires = DateTime.Now.AddDays(1);
    // //Response.Cookies.Add(aCookie);

    // //HttpCookie acookie = new HttpCookie("Loggedin");

    // //acookie.Name = "adelphia.us.com";
    // ////acookie.Path = "/";
    // //acookie.Domain = "adelphia.us.com";
    // //acookie.Value = "TRUE";
    // ////acookie.Path = Request.Path;
    // //acookie.Expires = DateTime.Now.AddDays(5);
    // ////Response.Cookies.Set(acookie);
    // //Response.Cookies.Add(acookie);
    // ////Request.Cookies.Add(acookie);
    // Server.Transfer("./main.aspx");

    // //Response.Redirect("",false);
    }
    // }

    //}
    protected void txtFirstName_TextChanged(object sender, EventArgs e)
    {

    }
    }

    Response.Redirect is a link to the homepage
    marsha27e, Feb 20, 2011
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Corbin O'Reilly
    Replies:
    2
    Views:
    3,161
    Corbin O'Reilly
    May 26, 2004
  2. jaanazam
    Replies:
    2
    Views:
    8,211
    ziyad6
    Aug 28, 2008
  3. nedums_b
    Replies:
    1
    Views:
    3,773
    ProgTalk
    Feb 7, 2008
  4. bredal Jensen
    Replies:
    8
    Views:
    4,350
  5. GusSalvador

    Changing the Master Page via the code behind page

    GusSalvador, Dec 2, 2009, in forum: General Computer Support
    Replies:
    0
    Views:
    1,935
    GusSalvador
    Dec 2, 2009
Loading...

Share This Page