Advertisement
Guest User

sqlconnection

a guest
May 25th, 2016
509
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. using System;
  2. using System.Data;
  3. using System.Data.SqlClient;
  4.  
  5. public partial class _Default : System.Web.UI.Page
  6. {
  7. protected void Page_Load(object sender, EventArgs e)
  8. {
  9.  
  10. }
  11.  
  12. protected void Button1_Click(object sender, EventArgs e)
  13. {
  14.  
  15. SqlConnection conn = new SqlConnection();
  16. conn.ConnectionString =
  17. "Data Source=test\testserver;" +
  18. "Initial Catalog=tidsregistering;" +
  19. "User id=zbcuser;" +
  20. "Password=Asdf1234;";
  21. conn.Open();
  22. SqlDataAdapter sda = new SqlDataAdapter("Select count(*) From Bruger Where brugernavn = '" + TextBox1.Text + "' and password= '" + TextBox2.Text + "'",conn);
  23. DataTable dt = new DataTable();
  24. sda.Fill(dt);
  25.  
  26. if (dt.Rows[0][0]. ToString() == "1")
  27. {
  28. Response.Redirect("Default2.aspx");
  29. }
  30. else
  31. {
  32. Label1.Visible = true;
  33. }
  34.  
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement