示例#1
0
        private void button2_Click(object sender, EventArgs e)
        {
            string Fname, Lname, contact;
            double gpa;

            Fname   = textBox2.Text;
            Lname   = textBox3.Text;
            contact = textBox5.Text;
            gpa     = Convert.ToDouble(textBox4.Text);
            try
            {
                Sql_Db_Connection connection = new Sql_Db_Connection(); // my db class
                string            query      = "DELETE FROM crud_table WHERE ID = '" + textBox1.Text + "' ";
                if (connection.insert_query(query))
                {
                    MessageBox.Show("Data Deleted Successfully");
                }
                else
                {
                    MessageBox.Show("Data could not be deleted");
                }
            }
            catch (Exception Ex)
            {
                MessageBox.Show(Ex.Message);
            }
        }
示例#2
0
        private void button2_Click(object sender, EventArgs e)
        {
            string id = textBox1.Text;

            string            query  = "SELECT * FROM crud_table Where ID=" + id;
            Sql_Db_Connection sql_Db = new Sql_Db_Connection();

            sql_Db.command = new SqlCommand(query, sql_Db.connection);
            try {
                sql_Db.dr = sql_Db.command.ExecuteReader();
                if (sql_Db.dr.Read())
                {
                    textBox2.Text = (sql_Db.dr["Fname"].ToString());
                    textBox3.Text = (sql_Db.dr["Lname"].ToString());
                    textBox4.Text = (sql_Db.dr["GPA"].ToString());
                    textBox5.Text = (sql_Db.dr["Contact"].ToString());
                    MessageBox.Show("User found");
                }
                else
                {
                    MessageBox.Show("User not Found");
                }
            }
            catch (Exception Ex) {
                MessageBox.Show(Ex.Message);
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            Sql_Db_Connection sql_Db        = new Sql_Db_Connection();
            string            query         = "SELECT * FROM crud_table";
            BindingSource     bindingSource = sql_Db.Select_Query(query);

            dataGridView1.DataSource = bindingSource;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            string Id, Fname, Lname, contact;
            double gpa;

            Id      = textBox5.Text;
            Fname   = textBox4.Text;
            Lname   = textBox3.Text;
            contact = textBox1.Text;
            gpa     = Convert.ToDouble(textBox2.Text);
            Sql_Db_Connection connection = new Sql_Db_Connection(); // my db class

            string query = "INSERT INTO Crud_Table VALUES('" + Id + "','" + Fname + "','" + Lname + "','" + gpa + "','" +
                           contact + "') ";

            if (connection.insert_query(query))
            {
                MessageBox.Show("Data Inserted Successfully");
            }
        }
示例#5
0
        private void button1_Click(object sender, EventArgs e)
        {
            string Fname, Lname, contact;
            double gpa;

            Fname   = textBox2.Text;
            Lname   = textBox3.Text;
            contact = textBox5.Text;
            gpa     = Convert.ToDouble(textBox4.Text);
            try
            {
                Sql_Db_Connection connection = new Sql_Db_Connection(); // my db class
                string            query      = "UPDATE crud_table SET Fname='" + Fname + "' , Lname = '" + Lname + "' , GPA = '" + gpa + "' , Contact ='" + contact + "' WHERE ID = '" + textBox1.Text + "' ";
                MessageBox.Show(query);
                if (connection.insert_query(query))
                {
                    MessageBox.Show("Data Updated Successfully");
                }
            }
            catch (Exception Ex)
            {
                MessageBox.Show(Ex.Message);
            }
        }