SQL update statement in C#

前端 未结 9 1698
陌清茗
陌清茗 2020-11-27 04:26

I have table \"Student\"

   P_ID   LastName  FirstName  Address  City

   1        Hansen    Ola                
   2        Svendson   Tov         


        
9条回答
  •  南笙
    南笙 (楼主)
    2020-11-27 05:13

    String st = "UPDATE supplier SET supplier_id = " + textBox1.Text + ", supplier_name = " + textBox2.Text
                + "WHERE supplier_id = " + textBox1.Text;
    
            SqlCommand sqlcom = new SqlCommand(st, myConnection);
            try
            {
                sqlcom.ExecuteNonQuery();
                MessageBox.Show("update successful");
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message);
            }
    

提交回复
热议问题