> For the complete documentation index, see [llms.txt](https://kythuat.dtechvn.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kythuat.dtechvn.com/cai-dat-dtech/loi-attach-data-khong-nhan.md).

# LỖI ATTACH DATA KHÔNG NHẬN

## Hướng dẫn

#### 1. Hướng dẫn attach data

* Cần phân quyền data và log data full quyền cho user everyone
* Đăng nhập exe, vào chức năng QL dữ liệu

#### 2. Nếu không attach data được&#x20;

* Kiểm tra đã phân quyền everyone data và log chưa?
* Thử cắt log đi sang thư mục khác và add lại
* Thử khởi động lại máy rồi add lại
* Thử khởi động lại sql rồi add lại
* Thử drop databse và attach lại bằng lệnh

```sql
-- Trước khi làm, hãy copy data ra thư mục khác
-- khi drop data có thể data sẽ bị xoá
-- xoá data BichHang. do Sql vẫn đang hiểu là quản lý data Bichhang
Drop database BichHang
-- attach lại data BichHang vào sql ( sử dụng khi mà dùng chức năng DL dữ liệu không được)
EXEC sp_attach_db @dbname = N'BichHang',   
    @filename1 =   
N'D:\Dtech\Data\BichHang.mdf',   
    @filename2 =   
N'D:\Dtech\Data\BichHang_log.ldf';  
-- nếu attach mà báo lỗi access denied, thì phân quyền full control cho data

```

* Có thể kiểm tra file log trong thư mục temp để đoán lỗi không add được
* nếu không được thì khả năng lỗi data


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kythuat.dtechvn.com/cai-dat-dtech/loi-attach-data-khong-nhan.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
