ASP.NET

Moderators: None (Apply to moderate this forum)
Number of threads: 1678
Number of posts: 3227

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Need help in Login Page Posted by Kristybegin on 2 Nov 2009 at 9:02 PM
There are errors which kept appearing which I cannot debug:

All my textboxes and buttons does not exist in the current context:



using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;



public partial class _Default : System.Web.UI.Page
{
DBConnect Connect = new DBConnect();
protected void Page_Load(object sender, EventArgs e)
{

if ((string)Session["sFlag"] == "T")

{

LoggedIn();


}
else
{
Session["sName"] = null;
Session["sUserName"] = null;
Session["sAddress"] = null;
Session["sCoContact"] = null;
Session["sPIC"] = null;
Session["sPICContact"] = null;
Session["sFlag"] = "F";
passwordTB.Visible = true;
passwordTB.Text = "";
usernameTB.Visible = true;
usernameTB.Text = "";
usernameTB.Text = "UserID:";
LogoutBT.Visible = false;
LoginBT.Visible = true;


}
}



protected void LoginBT_Click(object sender, EventArgs e)
{
if (usernameTB.Text != "")
{
if (passwordTB.Text != "")
{
OleDbConnection mdb = new OleDbConnection();
OleDbCommand cmd;
OleDbDataReader rdr;
Connect.DBConnection(mdb);
mdb.Open();
string SQLinfo = "SELECT * FROM Customers WHERE cUserName = '" +
usernameTB.Text.ToUpper() + "'";
string SQLlog = "INSERT INTO Log (lName,lLogIn) " +
"VALUES (@UserName, @Date)";
cmd = new OleDbCommand(SQLinfo, mdb);
rdr = cmd.ExecuteReader();
while (rdr.Read())
{
if (passwordTB.Text == (string)rdr["cPassword"])
{
Session["sName"] = rdr["cName"];
Session["sUserName"] = rdr["cUserName"];
Session["sAddress"] = rdr["cCoAddress"];
Session["sCoContact"] = rdr["cCoContact"];
Session["sPIC"] = rdr["cPersonInCharge"];
Session["sPICContact"] = rdr["cPICContact"];
Session["sEmail"] = rdr["cEmail"];
Session["sStatus"] = rdr["cStatus"];
Session["sFlag"] = "T";
rdr.Close();
cmd = new OleDbCommand(SQLlog, mdb);
cmd.Parameters.Add("@UserName", OleDbType.Char).Value = (string)Session["sCoName"];
cmd.Parameters.Add("@Date", OleDbType.Date).Value = DateTime.Now;
cmd.ExecuteNonQuery();
mdb.Close();
LoggedIn();
break;
}
else
{
rdr.Close();
mdb.Close();
usernameTB.Text = "";
passwordTB.Text = "";
Response.Write("<script>alert('Error signing in')</script>");
break;
}
}
mdb.Close();
}
else
{
passwordTB.Focus();
Response.Write("<script>alert('Please enter your password')</script>");
}
}
else
{
usernameTB.Focus();
Response.Write("<script>alert('Please enter your UserID')</script>");
}
}

protected void LogoutBT_Click(object sender, EventArgs e)
{
OleDbConnection mdb = new OleDbConnection();
OleDbCommand cmd;
Connect.DBConnection(mdb);
string SQLlog = "UPDATE Log SET lLogOut = @Date WHERE lCoName = @Name";
cmd = new OleDbCommand(SQLlog, mdb);
cmd.Parameters.Add("@Date", OleDbType.Date).Value = DateTime.Now;
cmd.Parameters.Add("@Name", OleDbType.Char).Value = (string)Session["sUserName"];
mdb.Open();
cmd.ExecuteNonQuery();
mdb.Close();
LoggedOut();
}
protected void LoggedOut()
{
Session["sName"] = null;
Session["sUserName"] = null;
Session["sAddress"] = null;
Session["sCoContact"] = null;
Session["sPIC"] = null;
Session["sPICContact"] = null;
Session["sFlag"] = "F";
passwordTB.Visible = true;
passwordTB.Text = "";
usernameTB.Visible = true;
usernameTB.Text = "";
usernameTB.Text = "UserID:";
LogoutBT.Visible = false;
LoginBT.Visible = true;
Response.Redirect("OnlineRVform.aspx");
}
protected void LoggedIn()
{
passwordTB.Visible = false;
passwordTB.Text = "";
usernameTB.Visible = false;
usernameTB.Text = "";
usernameTB.Text = (string)Session["sPIC"];
LogoutBT.Visible = true;
LoginBT.Visible = false;

}


Please help me. Thank you so much.
Report
Re: Need help in Login Page Posted by dotnetb4u on 4 Nov 2009 at 8:08 AM
pls paste error



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.