this is the code i have written for my login page.
the errors are at the bottem. i've only started using asp.net and cant fix the errors.
rotected void LoginButton_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
string username = Username.Text; //Get the username from the control
string password = Password.Text; //get the Password from the control
SqlCommand comm;
SqlConnection conn;
SqlDataAdapter dataAdapter;
SqlDataReader dataReader;
string connectionString = ConfigurationManager.ConnectionStrings["Dorknozzle"].ConnectionString;
comm = new SqlCommand("select Username, Password from tblEmployee where Username =" + username + "‘ AND Password =’" + password, conn);
DataSet userDS = new DataSet();
conn = new SqlConnection(connectionString);
conn.Open();
// execute the command
// dataReader = new SqlDataReader( conn);
dataReader = comm.ExecuteReader();
//Get the first row and check the password.
while (dataReader.Read())
{
if (dataReader["password"].ToString() == password)
Response.Redirect("Employee_Details.aspx");
/*else
{
dbError.Text = "Invalid password.";
}*/
}
/*else
{
dbErrorMessage.Text = "Login name not found.";
}*/
dataReader.Close();
conn.Close();
// Enclose database code in Try-Catch-Finally
/*try
{
// Open the connection
conn.Open();
// Execute the command
comm.ExecuteNonQuery();
// Reload page if the query executed successfully
Response.Redirect("Employee_Details.aspx");
}
catch
{
// Display error message
dbErrorMessage.Text =
"Error submitting employee details! Please " +
"try again later, and/or change the entered data!";
}
finally
{
// Close the connection
conn.Close();
}*/
}
Error 3 Cannot implicitly convert type 'string' to 'System.Web.UI.WebControls.TextBox' E:\Documents and Settings\student\Desktop\IES\Employee_Details.aspx 1
Error 4 The name 'Username' does not exist in the current context E:\Documents and Settings\student\Desktop\IES\Login.aspx.cs 28 35 E:\...\IES\
Error 5 The name 'Password' does not exist in the current context E:\Documents and Settings\student\Desktop\IES\Login.aspx.cs 29 35 E:\...\IES\
Error 6 The name 'dbError' does not exist in the current context E:\Documents and Settings\student\Desktop\IES\Employee_Details.aspx.cs 158 21 E:\...\IES\