Beispiel #1
0
        private void btnIn_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection(@"SERVER = DESKTOP-5HGTV4A; uid = sa; pwd = 12112014; DATABASE = QuanLyKhachSan");

            conn.Open();
            SqlCommand command = new SqlCommand("SELECT * FROM PhieuDangKy", conn);

            SqlDataAdapter adapter = new SqlDataAdapter(command);

            DataSet ds = new DataSet("tbPhieuDangKy");

            adapter.Fill(ds, "tbPhieuDangKy");
            conn.Close();

            rpPhieuDangKy rp = new rpPhieuDangKy();

            rp.DataSource = ds;
            rp.DataMember = ds.Tables["tbPhieuDangKy"].TableName;
            rp.ShowPreview();
        }
        private void btnIn_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection(@"SERVER = DESKTOP-5HGTV4A; uid = sa; pwd = 12112014; DATABASE = QuanLyKhachSan");

            conn.Open();
            string     sql     = "select * from PhieuDangKy where MaPhieuDK = '" + txtTuKhoa.Text + "'";
            SqlCommand command = new SqlCommand(sql, conn);

            SqlDataAdapter adapter = new SqlDataAdapter(command);

            DataSet ds = new DataSet("tbPhieuDangKy");

            adapter.Fill(ds, "tbPhieuDangKy");
            conn.Close();



            rpPhieuDangKy rp = new rpPhieuDangKy();

            rp.DataSource = ds;
            rp.DataMember = ds.Tables["tbPhieuDangKy"].TableName;
            rp.ShowPreview();
        }