Guest User

Untitled

a guest
Oct 21st, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 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;
  8. using System.Data.SqlClient;
  9.  
  10. namespace MechWorks.Account
  11. {
  12. public partial class Register : System.Web.UI.Page
  13. {
  14. protected void Page_Load(object sender, EventArgs e)
  15. {
  16.  
  17. }
  18.  
  19. protected void ButLogin_Click(object sender, EventArgs e)
  20. {
  21. SqlConnection con = new SqlConnection(@"Data Source=.SQLEXPRESS;Initial Catalog=Work;Integrated Security=True;");
  22. SqlCommand cmd = new SqlCommand("select * from test where cUsername=@username and cPassword=@word", con);
  23. cmd.Parameters.AddWithValue("@username", UserTxt.Text);
  24. cmd.Parameters.AddWithValue("word", PasTxt.Text);
  25. SqlDataAdapter sda = new SqlDataAdapter(cmd);
  26. DataTable dt = new DataTable();
  27. sda.Fill(dt);
  28. con.Open();
  29. int i = cmd.ExecuteNonQuery();
  30. con.Close();
  31. if (dt.Rows.Count > 0)
  32. {
  33. Session["id"] = UserTxt.Text;
  34. Response.Redirect("Redirectform.aspx");
  35. Session.RemoveAll();
  36. }
  37. else
  38. {
  39. Label1.Text = "You're username and word is incorrect";
  40. Label1.ForeColor = System.Drawing.Color.Red;
  41. }
  42. }
  43. }
  44. }
Add Comment
Please, Sign In to add comment