Ejemplo n.º 1
0
        private void roundButton2_Click(object sender, EventArgs e)
        {
            using (SqlConnection sqlCon = new SqlConnection(connectionString))
            {
                sqlCon.Open();
                SqlCommand sqlcmd  = new SqlCommand("", sqlCon);
                SqlCommand sqlcmd1 = new SqlCommand("", sqlCon);

                int x = int.Parse(label4.Text);
                if (login.hs < x)
                {
                    sqlcmd.CommandText = $@"update user2 set highscore='" + x + "' where username= '******'";
                    sqlcmd.ExecuteNonQuery();
                }
                sqlCon.Close();
            }
            login ss = new login();

            ss.Show();
            this.Hide();
        }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection Con = new SqlConnection(@"Data Source=(localdb)\ProjectsV13;Initial Catalog=login;Integrated Security=True;Connect Timeout=30");

            try
            {
                Con.Open();

                SqlCommand cmd = new SqlCommand("insert into [Table] values('" + mail.Text + "','" + nam.Text + "','" + pwd.Text + "','" + age.Text + "')", Con);
                cmd.ExecuteNonQuery();
                MessageBox.Show("Account created!", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Hide();
                var log = new login();
                log.Show();
            }
            catch (SqlException E)
            {
                Console.WriteLine(E);
                MessageBox.Show("Failure!", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            Con.Close();
        }