Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Data.SqlClient;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- namespace WebApplication1
- {
- public partial class LoginPage : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
- {
- String mycon = "Data Source=DESKTOP-LGI18UP;Initial Catalog=haritiShopping;Integrated Security = True";
- SqlConnection scon = new SqlConnection(mycon);
- String myquery = "select * from logindetails";
- SqlCommand cmd = new SqlCommand();
- cmd.CommandText = myquery;
- cmd.Connection = scon;
- SqlDataAdapter da = new SqlDataAdapter();
- da.SelectCommand = cmd;
- DataSet ds = new DataSet();
- da.Fill(ds);
- String uname;
- String pass;
- uname = ds.Tables[0].Rows[0]["username"].ToString();
- pass = ds.Tables[0].Rows[0]["password"].ToString();
- scon.Close();
- if (uname == TextBox1.Text && pass == TextBox2.Text)
- {
- Response.Redirect("MainPage.aspx");
- }
- else
- {
- Label1.Text = "Invalid Username or Password - Relogin with Correct Username Password";
- }
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- String mycon = "Data Source=DESKTOP-LGI18UP;Initial Catalog=haritiShopping;Integrated Security = True";
- SqlConnection scon = new SqlConnection(mycon);
- SqlCommand cmd = new SqlCommand("select * from logindetails where UserName =@username and Password=@password", scon);
- cmd.Parameters.AddWithValue("@username", TextBox1.Text);
- cmd.Parameters.AddWithValue("@password", TextBox2.Text);
- SqlDataAdapter da = new SqlDataAdapter(cmd);
- DataTable dt = new DataTable();
- da.Fill(dt);
- if (dt.Rows.Count > 0)
- {
- Response.Redirect("MainPage.aspx");
- }
- else
- {
- Label1.Visible = true;
- Label1.Text = "Wrong password or nickname";
- }
- }
- /*protected void Button1_Click(object sender, EventArgs e)
- {
- String mycon = "Data Source=DESKTOP-LGI18UP;Initial Catalog=haritiShopping;Integrated Security = True";
- SqlConnection scon = new SqlConnection(mycon);
- String myquery = "select * from logindetails";
- SqlCommand cmd = new SqlCommand();
- cmd.CommandText = myquery;
- cmd.Connection = scon;
- SqlDataAdapter da = new SqlDataAdapter();
- da.SelectCommand = cmd;
- DataSet ds = new DataSet();
- da.Fill(ds);
- String uname;
- String pass;
- uname = ds.Tables[0].Rows[0]["username"].ToString();
- pass = ds.Tables[0].Rows[0]["password"].ToString();
- scon.Close();
- if (uname == TextBox1.Text && pass == TextBox2.Text)
- {
- Response.Redirect("MainPage.aspx");
- }
- else
- {
- Response.Redirect("MainPage.aspx");
- }
- }
- */}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement