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:

         private void button1_Click(object sender, EventArgs e)
         {
             if (txt1.Text == "" || txt2.Text == "" || txt6.Text == "")
             {
                 MessageBox.Show("Bạn phải nhập giá trị vào các ô có dấu *");
             }
             else
             {
                 string TenDangNhap = txt1.Text;
                 string MatKhau = txt2.Text;
                 string HoVaTen = txt3.Text;
                 string NgaySinh = txt4.Text;
                 string NoiSinh = txt5.Text;
                 string SoDienThoai = txt6.Text;

                 string strSQL = "insert THISINH values('" + TenDangNhap + "','" + MatKhau + "','" + HoVaTen + "','" + NgaySinh + "','" + NoiSinh + "','" + SoDienThoai + "')";
                 SqlCommand ObjCmd = new SqlCommand(strSQL, ObjCon);
                 ObjCmd.ExecuteNonQuery();
                 MessageBox.Show("Bạn đã đăng ký thành công");
                 this.Close();
             }
         }