using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.Security;
using System.Data.OleDb;
using System.Configuration;
namespace hepsi_web_form
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox txtUserName;
protected System.Web.UI.WebControls.RequiredFieldValidator rvUserNameValidator;
protected System.Web.UI.WebControls.TextBox txtPassword;
protected System.Web.UI.WebControls.RequiredFieldValidator rvPasswordValidator;
protected System.Web.UI.WebControls.ValidationSummary validationSummery1;
protected System.Web.UI.WebControls.Label lblMessage;
protected System.Web.UI.WebControls.Label lblMessage2;
protected System.Web.UI.WebControls.Button cmdSubmit;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}
private void InitializeComponent()
{
this.cmdSubmit.Click += new System.EventHandler(this.cmdSubmit_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void cmdSubmit_Click(object sender, System.EventArgs e)
{
if (Page.IsValid)
{
if (DBConnection(txtUserName.Text.Trim(), txtPassword.Text.Trim()))
{
FormsAuthentication.RedirectFromLoginPage (txtUserName.Text, false);
}
else
{
lblMessage.Text = "Invalid Login, please try again!";
}
}
Response.Redirect("secimForm.aspx");
}
private bool DBConnection(string txtUser, string txtPass)
{
OleDbConnection myConn = new OleDbConnection(ConfigurationSettings.AppSettings["strConn"]);
OleDbCommand myCmd = new OleDbCommand("EMPLOYEES", myConn);
myCmd.CommandType = CommandType.StoredProcedure;
OleDbParameter objParam1;
OleDbParameter objParam2;
OleDbParameter returnParam;
objParam1 = myCmd.Parameters.Add ("@FIRST_NAME", OleDbType.VarChar);
objParam2 = myCmd.Parameters.Add ("@EMPLOYEE_ID", OleDbType.VarChar);
returnParam = myCmd.Parameters.Add ("@NUMBER_OF_EMP", OleDbType.VarChar);
objParam1.Direction = ParameterDirection.Input;
objParam2.Direction = ParameterDirection.Input;
returnParam.Direction = ParameterDirection.Input;
objParam1.Value = txtUser;
objParam2.Value = txtPass;
try
{
if (myConn.State.Equals(ConnectionState.Closed))
{
myConn.Open();
myCmd.ExecuteNonQuery();
}
OleDbDataReader objReader;
objReader = myCmd.ExecuteReader(CommandBehavior.CloseConnection);
if ((int)returnParam.Value < 1)
{
lblMessage.Text = "Invalid Login!";
return false;
}
else
{
myConn.Close();
return true;
}
}
/* while(objReader.Read())
{
if (objReader.GetValue(0) = 0)
{
lblMessage.Text = "Invalid Login!";
//return false;
}
else
{
objReader.Close();
return true;
}
}*/
catch (Exception ex)
{
lblMessage2.Text = ex + "Error Connecting to the database";
return false;
}
}
}
}
this my code ı have problem with this my Error is :
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested Url: /hepsi_web_form/secimForm.aspx
My database is Oracle 9i