[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 330
  • Last Modified:

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

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.

0
tommym121
Asked:
tommym121
  • 3
2 Solutions
 
skaraiCommented:
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.
0
 
sachinpatil10dCommented:
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.

0
 
tommym121Author Commented:
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: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.50.1617.0+((KJ_RTM_GDR).110422-1901+)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Attach+database+Server&LinkId=20476

------------------------------
ADDITIONAL INFORMATION:

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: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.50.1600&EvtSrc=MSSQLServer&EvtID=5120&LinkId=20476

------------------------------
BUTTONS:

OK
------------------------------
0
 
tommym121Author Commented:
Got it I need to give write permission to the database file   Thanks.
0
 
tommym121Author Commented:
Thanks.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now