What can I do with a SQL Server Database Primary Data File and Transaction file

Posted on 2011-10-31
Last Modified: 2012-05-12
I am going through a ADO.Net Training Kit from a book.  It comes with a Database Primary Data File and Transaction file.   How do I install the database to  work on ADO.Net Exercises.

Question by:tommym121
    LVL 7

    Accepted Solution

    Typically you would copy the provided files to the SQL server first - for this exercise you can create a directory called MSSQL\Data off the root of your c drive. Copy both files there. Then inside SQL management studio right click your SQL server and under tasks attach the database by browsing to the directory and point it at the .mdf file for the database file. You may have to point it to the .ldf file for the log file in case SQL isnt finding it automatically. Only if SQL can 'see' both files will you have a chance for an easy attach approach.
    LVL 9

    Assisted Solution

    Open Sqlserver>>InstanceName>>Databases>>right click>>Attach...

    Attach Database Window appears

    click on Add button
    give the path of the .mdf file click ok>>ok

    new database will appear in the Databases list

    change the connection string from your  ADO.Net Training Kit Exercises(sqlserver instance name)

    and run the ADO.Net Exercises.


    Author Comment

    I got the following errors when I try to attach the database.

    TITLE: Microsoft SQL Server Management Studio

    Attach database failed for Server 'GUNDAMZ\SQLTEST'.  (Microsoft.SqlServer.Smo)

    For help, click:


    An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)


    Unable to open the physical file "C:\MSSQL\DATA\VideoGames.mdf". Operating system error 5: "5(failed to retrieve text for this error. Reason: 15105)". (Microsoft SQL Server, Error: 5120)

    For help, click:



    Author Comment

    Got it I need to give write permission to the database file   Thanks.

    Author Closing Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now