Advertisement
Guest User

Sign-in

a guest
May 22nd, 2016
738
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using System.Data.SqlClient;
  8. using System.Configuration;
  9. using System.Data;
  10.  
  11. namespace WebApplication1
  12. {
  13. public partial class SignIn : System.Web.UI.Page
  14. {
  15. protected void Page_Load(object sender, EventArgs e)
  16. {
  17.  
  18. }
  19.  
  20.  
  21. protected void Button1_Click(object sender, EventArgs e)
  22. {
  23. String CS = ConfigurationManager.ConnectionStrings["MyDatabaseConnectionString1"].ConnectionString;
  24. using (SqlConnection con = new SqlConnection(CS)) {
  25. SqlCommand cmd= new SqlCommand("select * from Users where Username='"+ Username.Text+"' and Password='"+Password.Text+"'" , con);
  26. con.Open();
  27. SqlDataAdapter sda = new SqlDataAdapter(cmd);
  28. DataTable dt = new DataTable();
  29. sda.Fill(dt);
  30. if (dt.Rows.Count != 0)
  31. {
  32. Session["USERNAME "] = Username.Text;
  33. Response.Redirect("~/UserHome.aspx"); }
  34. else {
  35. lblError.Text = "Invalid Username or Password !";
  36.  
  37. }
  38.  
  39.  
  40. }
  41. }
  42.  
  43.  
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement