private void button3_Click(object sender, EventArgs e)
{
String s = "data
source=ACER-PC\\SQLEXPRESS;database = hr;integrated security = SSPI";
SqlConnection c = new SqlConnection(s);
try {
if (textBox1.Text == ""){
MessageBox.Show("Enter Id To Update");
} else
{
SqlCommand cmdupdate = new SqlCommand("Update tblEmployees
SET name='" + textBox2.Text + "' where id=" +
textBox1.Text + "", c);
c.Open();
cmdupdate.CommandType = CommandType.Text;
cmdupdate.ExecuteNonQuery();
MessageBox.Show("Data Updated");
}
}
catch (Exception ex){
MessageBox.Show(ex.Message);
}
finally{
if (c.State == ConnectionState.Open){
c.Close();
} } } }}
Tidak ada komentar:
Posting Komentar