Showing posts with label c# code for forget password using sql server. Show all posts
Showing posts with label c# code for forget password using sql server. Show all posts

Wednesday, May 18, 2016

Code for forgot password using ADO.Net and C#


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace WindowsFormsApplication21
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }
        SqlDataAdapter da;
        DataSet ds;
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            comboBox1.Items.Add("nickname");
        }
        private void Form2_Load(object sender, EventArgs e)
        {
            da = new SqlDataAdapter("select * from login1", "data source=MKS-PC\\SQLEXPRESS;Initial Catalog=master;integrated security=true");
            ds = new DataSet();
            da.Fill(ds);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            bool b = true;
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                if (dr[0].ToString().Trim() == textBox1.Text && dr[3].ToString().Trim() == textBox2.Text)
                {
                    MessageBox.Show(dr[1].ToString());
                    b = false;
                }
            }
            if (b)
            {
                MessageBox.Show("Wrong uid or ans");
            }
        }
    }
}

Output
 Click on "forgetpassword" button a new window will be open now fill "uid","select ques", "ans" Information and click on submit button