Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Data;
- using System.Data.SqlClient;
- namespace MechWorks.Account
- {
- public partial class Register : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- protected void ButLogin_Click(object sender, EventArgs e)
- {
- SqlConnection con = new SqlConnection(@"Data Source=.SQLEXPRESS;Initial Catalog=Work;Integrated Security=True;");
- SqlCommand cmd = new SqlCommand("select * from test where cUsername=@username and cPassword=@word", con);
- cmd.Parameters.AddWithValue("@username", UserTxt.Text);
- cmd.Parameters.AddWithValue("word", PasTxt.Text);
- SqlDataAdapter sda = new SqlDataAdapter(cmd);
- DataTable dt = new DataTable();
- sda.Fill(dt);
- con.Open();
- int i = cmd.ExecuteNonQuery();
- con.Close();
- if (dt.Rows.Count > 0)
- {
- Session["id"] = UserTxt.Text;
- Response.Redirect("Redirectform.aspx");
- Session.RemoveAll();
- }
- else
- {
- Label1.Text = "You're username and word is incorrect";
- Label1.ForeColor = System.Drawing.Color.Red;
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment