Guest User

Untitled

a guest
Dec 3rd, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. using System;
  2. using System.Data;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using System.Collections.Generic;
  8. using System.Data.SqlClient;
  9. using System.Configuration;
  10.  
  11. namespace WebApplication21
  12.  
  13. {
  14. public partial class WebForm1 : System.Web.UI.Page
  15. {
  16. protected void Page_Load(object sender, EventArgs e)
  17. {
  18.  
  19. }
  20. protected void Button1_Click(object sender, EventArgs e)
  21. {
  22.  
  23. SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["dbconnection"].ConnectionString);
  24. con.Open();
  25. SqlCommand cmd = new SqlCommand("select * from 'user_insert' where username = @username and password = @password,con");
  26. cmd.Parameters.AddWithValue("@username", TextBox1.Text);
  27. cmd.Parameters.AddWithValue("@password", TextBox2.Text);
  28. SqlDataAdapter da = new SqlDataAdapter(cmd);
  29. DataTable dt = new DataTable();
  30. da.Fill(dt);
  31.  
  32. if (dt.Rows.Count > 0)
  33. {
  34. Response.Redirect("Welcom.aspx");
  35. }
  36. else
  37. {
  38. Response.Redirect("Error.aspx");
  39. }
  40.  
  41. }
  42.  
  43. <connectionStrings>
  44. <add name="dbconnection" connectionString="Data Source=Ali-PC;Initial Catalog=LogIn;Integrated Security=True"/>
  45. </connectionStrings>
  46.  
  47. SqlCommand cmd = new SqlCommand
  48. (@"select * from 'your table' where username = @username and password = @password",con);
  49. cmd.Parameters.AddWithValue("@username", TextBox1.Text);
  50. cmd.Parameters.AddWithValue("@password", TextBox2.Text);
  51.  
  52. DataTable dt = new DataTable();
  53. dt.Load(cmd.ExecuteReader());
Add Comment
Please, Sign In to add comment