Lỗi an error occurred when attaching the database năm 2024

Step 1 Right-click “Databases” and click the “Attach” option to open the Attach Databases dialog box.

Step 2 Click the “Add” button to open the Locate Database Files dialog box.

Step 3 Type in the full name of the .MDF file, including the full device and directory path, as the following example illustrates: c:\StudentsDB.mdf Click the "OK" button. SQL Server Management Studio loads the database from the .MDF file.

OR

Step 1 Click “New Query” in the Management Studio’s main toolbar.

Step 2 Type a Create Database statement using the following Transact-SQL code: CREATE DATABASE MyDatabase ON [FILENAME = 'c:\StudentsDB.mdf'], [FILENAME = ' c:\StudentsDB.ldf'] FOR ATTACH;

Step 3 Click the “Execute” button in the Transact-SQL toolbar. SQL Server Management Studio restores the database.

Lỗi error 5 là lỗi phát sinh khi quyền truy cập của bạn bị giới hạn bởi lý do là bạn đang thiết lập hệ thống SQL Log on as: This account. Chỉ cần vào Sql Server Configuration Manager ở mục Log On ta chọn Built-in account: Local System. Như vậy là bạn đã có thể thêm một database từ file có sẵn vào SQL Server Management Studio của mình. Phiên bản bài viết sử dụng là phiên bản SQL Server 2014 Management Studio.

Điều hướng bài viết

Khi attach database SQL Server thì hiện thông báo lỗi "An error occurred when attaching the database..." và không attach được [ảnh dưới]. Bài viết này sẽ hướng dẫn cách khắc phục lỗi.

Thông báo lỗi "An error occurred when attaching the database..." trong SQL Server

[1] Hãy kiểm tra lại thư mục chứa database SQL Server đã đặt đúng vị trí của thư mục hay chưa, ví dụ: vị trí thưc mục chứa database của Dân Trí Soft mặc định sẽ được đặt tại ổ đĩa D>>>DanTriSoft>>>POS/Restaurant/Bida_Karaoke>>Database. Nếu vị trí chưa đúng hãy khai báo theo đúng thông tin mặc định theo đường dẫn trên [chú ý: có thể thay thế ổ đĩa D thành ổ E, F, G..., miễn là không phải ổ đĩa hệ thống C là được].

[2] Kiểm tra lại tên database viết theo kiểu tiếng Anh hết chưa, nhiều trường hợp vì đặt tên theo tiếng Việt [có dấu] nên không attach database được.

[3] Nếu cả 2 trường hợp trên đều OK nhưng vẫn không attach database được thì xem cách xử lý ở video bên dưới, bản chất là phân quyền truy cập database.

[4] Nếu vẫn không được nữa, cách tốt nhất bạn hãy nhờ người có kiến thức về xử lý dữ liệu SQL Server để xem xét và khắc phục.

Bộ phận kỹ thuật DanTriSoft biên tập.

An error occurred when attaching the database[s]. Click the hyperlink in the Message column for details.

The detailed message is as follows.

Step 1:

Right, Click on the .mdf that you want to attach and click on Properties.

Step 2:

Go to Security tab and give Full Control to all Users and Groups by clicking on Edit.

Click on the Check Box under Allow section for Giving Full Control to all Users and Groups.

Step 3:

Right-click on the Main Folder containing your .mdf file and go to the properties section.

Deselect the “Read Only Option” in “General Tab” and click on Apply.

Step 4:

Go to the “Security Tab” and give “Full Control” to all “Groups and User Names” as shown in Step 2 and click on Apply.

Select “Apply changes to this folder, subfolder and files” option and click on “Ok”.

Click on “Ok” to apply all the changes.

Step 5:

Now go to SQL and Attach your .mdf file Again and your DB will be attached to the Databases folder and you can access it.

Check out my other blog here //www.cloudfronts.com/blog/dynamics-nav/performing-update-operation-in-microsoft-dynamics-nav-through-integration-in-tibco-cloud-integration/

Chủ Đề