You need to use SqlConnection object which is passed connection string which points it to connect to the appropriate database.
Once you got connection object ready, you can create SqlCommand object which contains the actual insert/update/delete/select command to be executed.
You can do it as below:
SqlConnection conn = new SQLConnection("Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;");
SqlCommand cmd = new SqlCommand("update persons set name='abc' where id =2 ");
cmd.Connection = conn;
cmd.ExecuteNonQuery();
To run the above code, you need to include import System.Data.SqlClient reference in your class.