Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > General Computer Discussion > General Computer Support > Code Behind Help

Reply
Thread Tools

Code Behind Help

 
 
marsha27e marsha27e is offline
Junior Member
Join Date: Feb 2011
Posts: 1
 
      02-20-2011
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 http://www.velocityreviews.com/forums/(E-Mail Removed).";

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

//send new user an email
//sendNewUserMail.SendMail("(E-Mail Removed)", usr.EmailAddress, "NEW USER CONFIRMATION", newuserEmailBody);

//send Admin email
//sendNewUserMail.SendMail("(E-Mail Removed)", "(E-Mail Removed)", "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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Non-code behind to code behind John ASP .Net 2 02-19-2007 07:08 PM
what is the difference between code inside a <script> tag and code in the code-behind file? keithb ASP .Net 1 03-29-2006 01:00 AM
Code-Behind Pain in the Behind! Daniel Manes ASP .Net 11 06-10-2005 09:47 PM
Fire Code behind code AND Javascript code associated to a Button Click Event =?Utf-8?B?Q2FybG8gTWFyY2hlc29uaQ==?= ASP .Net 4 02-11-2004 07:31 AM
Re: Code Behind vs. no code behind: error Ben Miller [msft] ASP .Net 1 06-28-2003 01:46 AM



Advertisments