Sunday, September 3, 2017

C# Windows application update

In our previous lesson, You learn that how to delete data from SQL server by c# windows application. In this lesson, we learn how to update that data.



First, add button from Toolbox and name it updates, that you learn from the first lesson.   

Then click button update and paste this code.

       private void button4_Click(object sender, EventArgs e)
        {
            con.Open();
            SqlCommand cmd = con.CreateCommand();
            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "update yy set name ='" + textBox2.Text + "' where id ='" +       textBox3.Text + "'";
            cmd.ExecuteNonQuery();
            con.Close();
            display();
            MessageBox.Show("Update Successful");

        }   

Then we save the code.Now click on start for execute the code. 
















Now write down the id you want to update and press the update button.

No comments:

Post a Comment