コード例 #1
0
        public List<GetAllTinhThanhViewModels> GetAllTinhThanh()
        {
            HtmlHelperGeneral.openConnection();
            SqlCommand sqlCommand = new SqlCommand();
            sqlCommand.CommandText = "GetAllTinhThanh";
            sqlCommand.CommandType = CommandType.StoredProcedure;

            sqlCommand.Connection = HtmlHelperGeneral.con;
            SqlDataReader reader = sqlCommand.ExecuteReader();
            List<GetAllTinhThanhViewModels> acDetails = new List<GetAllTinhThanhViewModels>();
            while (reader.Read())
            {
                GetAllTinhThanhViewModels h = new GetAllTinhThanhViewModels();
                h.TinhThanhID = reader.GetInt32NullCheck(0);
                h.maTinhThanh = reader.GetStringNullCheck(1);
                h.tenTinhThanh = reader.GetStringNullCheck(2);
                acDetails.Add(h);
            }
            HtmlHelperGeneral.Close();
            return acDetails;
        }
コード例 #2
0
        public List<GetAllTinhThanhViewModels> GetAllTinhThanh()
        {
            SqlConnection sqlConnection = new SqlConnection();
            sqlConnection.ConnectionString = MyConnectionString1;
            SqlCommand sqlCommand = new SqlCommand();
            sqlCommand.CommandText = "GetAllTinhThanh";
            sqlCommand.CommandType = CommandType.StoredProcedure;

            sqlCommand.Connection = sqlConnection;
            sqlConnection.Open();
            SqlDataReader reader = sqlCommand.ExecuteReader();
            List<GetAllTinhThanhViewModels> acDetails = new List<GetAllTinhThanhViewModels>();
            while (reader.Read())
            {
                GetAllTinhThanhViewModels h = new GetAllTinhThanhViewModels();
                h.TinhThanhID = reader.GetInt32NullCheck(0);
                h.maTinhThanh = reader.GetStringNullCheck(1);
                h.tenTinhThanh = reader.GetStringNullCheck(2);
                acDetails.Add(h);
            }
            return acDetails;
        }