Copying and Pasting cs Code

In cs, like in almost any computer programming language, reading data from a file can be tricky. You add extra lines of code to tell the computer what to do. Sometimes you can copy and paste these lines from other peoples’ code.

For example, you can follow the pattern in this listing:

         void Load_DeThiThat()
         {
             try
             {
                 SqlConnection cnn = new SqlConnection("server=.\\SQLEXPRESS;database=QL_Thitracnghiem;integrated security =true");
                 SqlDataAdapter da = new SqlDataAdapter("select cauhoi.mach,cauhoi,a,b,c,d ,dapan from cauhoi,DAPAN where cauhoi.mach=DAPAN.mach", cnn);
                 DataTable BangQuestion = new DataTable();
                 da.Fill(BangQuestion);
                 TaoBangRandomCauHoi(BangQuestion);
             }
             catch (Exception ex)
             { MessageBox.Show(ex.Message); }
             p = 60;//nhap thoi gian thi
             s = 60;
             h = 0;
         }