Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Data.SqlClient;
- using System.Xml.Linq;
- using System.Web.Security;
- using System.Data;
- public partial class login : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- protected void loginB_Click(object sender, EventArgs e)
- {
- string struser = usertxt.Text;
- string strpass = passtxt.Text;
- string s;
- string strSelect = "SELECT count (*) FROM ADMIN WHERE USERNAME = '" + struser + "' AND PASSWORD = '" + strpass + "' ";
- SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename='F:\adva\authentication\midterm\App_Data\Store.mdf';Integrated Security=True;MultipleActiveResultSets=True;Application Name=EntityFramework");
- SqlDataAdapter sda = new SqlDataAdapter("Select count (*) from ADMIN WHERE USERNAME = '" + usertxt.Text + "'AND PASSWORD = '" + passtxt.Text +"'",con);
- SqlCommand cmd = new SqlCommand(strSelect, con);
- DataTable dt = new DataTable();
- sda.Fill(dt);
- if (dt.Rows[0][0].ToString() == "1")
- {
- Session["user_id"] = struser;
- Response.Redirect("AddItems.aspx");
- }
- else
- {
- Response.Redirect("login.aspx");
- }
- // SqlDataReader myReader = cmd.ExecuteReader();
- /* s = cmd.ExecuteScalar().ToString();
- Boolean auth = false;
- if (s=="1")
- {
- // auth = true;
- Session["user"] = struser;
- Response.Redirect("adminMenu.aspx");
- }
- // myReader.Close();
- con.Close();
- if (auth == true)
- {
- // auth success
- // redirect to menu.aspx
- Response.Redirect("adminMenu.aspx");
- }
- else
- {
- // show an error message
- usertxt.Text = "wrong!";
- }
- */
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement