Inside web.config
Expand|Select|Wrap|Line Numbers
- <configuration> <appSettings> <add key="Connection" value="server=.;trusted_connection=true;initial catalog=sanjay"/> </appSettings></configuration>
Expand|Select|Wrap|Line Numbers
- private string username;
- private string password;
- public string UserName
- {
- get { return username; }
- set { username = value; }
- }
- public string PassWord
- {
- get { return password; }
- set { password = value; }
- }
- public int checking(string username,string password)
- {
- int temp = 0;
- SqlDataReader dr;
- string con = ConfigurationManager.AppSettings["Connection"].ToString(); SqlConnection connection = new SqlConnection(con); connection.Open();
- SqlCommand cmd = new SqlCommand("select * from pass where username='" + username + "' ", connection);
- dr = cmd.ExecuteReader();
- while (dr.Read())
- {
- string a = dr.GetValue(0).ToString();
- string b = dr.GetValue(1).ToString();
- if ((a.Equals(username)) && (b.Equals(password)))
- {
- temp= 1;
- }
- else
- {
- temp= 0;
- }
- }
- return temp;
- dr.Close();
- connection.Close();
- }
Expand|Select|Wrap|Line Numbers
- public int checking(string username,string password)
- {
- Dal d = new Dal();
- return d.checking(username,password);
- }
Expand|Select|Wrap|Line Numbers
- protected void Button1_Click(object sender, EventArgs e)
- {
- string uname = TextBox1.Text;
- string pwd = TextBox2.Text;
- if (Convert.ToBoolean(b.checking(uname,pwd)))
- {
- Button1.Text = "valid";
- }
- else
- {
- Button1.Text = "Invalid";
- }
- }
Thanks
Regards
Raghul