private void button1_Click(object sender, EventArgs e)
        {
            int    count            = 0;
            string connectionString = "Data Source=.;Initial Catalog=MyAppointmentDb;Integrated Security=True;Pooling=False";
            string query            = "Insert Into [Login] Values('" + tbxUName.Text + "', '" + tbxPword2.Text + "')";

            SqlConnection conn = new SqlConnection(connectionString);
            SqlCommand    cmd  = new SqlCommand(query, conn);

            conn.Open();
            if (tbxPword2.Text == tbxConPword.Text)
            {
                count += cmd.ExecuteNonQuery();
                conn.Close();
            }
            else
            {
                MessageBox.Show("Password and Confirm Password do not match");
            }
            if (count == 1)
            {
                ClientDetails clientDetails = new ClientDetails();
                clientDetails.Show();
                this.Close();
            }
        }
Example #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            int    count            = 0;
            string connectionString = "Data Source=.;Initial Catalog=MyAppointmentDb;Integrated Security=True;Pooling=False";
            string query            = "Select * From [Login] Where UserName = '******' And [Password] = '" + tbxPword.Text + "'";

            SqlConnection  conn = new SqlConnection(connectionString);
            SqlDataAdapter da   = new SqlDataAdapter(query, conn);
            DataTable      dt   = new DataTable();

            try
            {
                count += da.Fill(dt);

                if (count == 1)
                {
                    ClientDetails clientDetails = new ClientDetails();
                    clientDetails.Show();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("Invalid Credentials");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }