Wrox Programmer Forums
|
BOOK: Beginning SQL Server 2005 Programming ISBN: 978-0-7645-8433-6
This is the forum to discuss the Wrox book Beginning SQL Server 2005 Programming by Robert Vieira; ISBN: 9780764584336
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning SQL Server 2005 Programming ISBN: 978-0-7645-8433-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 16th, 2008, 04:12 PM
Registered User
 
Join Date: Nov 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Attaching Sample Databases

I have been trying to attach the Sample Databases (which evidentially are now supplied by CODEX instead of Microsoft. I notice that many of the sample files said they could not be used on the SQL Server 2005 Express. However, I did not see that restriction on the first download selection, so that is the file I downloaded.

I am a complete novice to SQL although I have been a database programmer using Access for years. When I downloaded the above file it installed automatically, Then when I tried to attach (which I think is the right thing to do) I received this message ....

Msg 5120, Level 16, State 101, Line 1
Unable to open the physical file "C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorks_Data.mdf" . Operating system error 5: "5(Access is denied.)".

DOES THAT MEAN I CANNOT USE THE FILES ON THE SQL SERVER 2005 EXPRESS?? If so, are there any other sample files for the Adventure Works I can use that are compatible with the SQL Server 2005 Express.

Please Help ... anyone! And, if this sample DB should attach please let me know if I have not been typing in the right code?

exec sp_attach_db @dbname = N'AdventureWorks', @filename1 = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorks_Data.mdf' , @filename2 = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorks_log.ldf'

I have verified that the files did install into the correct folder, and that folder is where my master.db is. And, when I installed my SQL 2005 Express I did install a default instance.

CAN ANYONE HELP ME? Codex does not support this, and I have not gotten any responses on their discussion forum.


 
Old November 17th, 2008, 04:27 PM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Might just be a folders/file permission problem. "Access is denied" is indeed a normal Windows OS error.

Try going to the folder containing the file(s) and adding the "Everyone" user and giving full permissions to that user for both those files. Since the directory they are in is surely accessible to SQL Server, it's most likely just the fact that the files are downloaded that causes the problem.

OH! WAIT! I wonder if all you need to do is UNBLOCK those files! Use Windows Explorer (or My Computer) and navigate to that directory. *RIGHT CLICK* on one of the files and then select "Properties" from the popup menu. If you see a button labelled "UNBLOCK", click on it. You should see the explanation as to why this is needed just to the left of the button.
 
Old November 18th, 2008, 11:32 PM
Registered User
 
Join Date: Nov 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Old Pedant,

Thank you so much for your suggestion. I am only using Windows XP and did not see anything in the Properties that set any kind of permission, like a Windows Server would. However, it did get me checking everything and the MSSL.1 folder was Read Only. Even though I kept taking it off it just would go back to read only. But, I took it off, left the Properties box open, ran my query and it worked. The AdventureWorks was attached!!!!!

Thanks sooooo much! I had given up and was getting ready to move onto something else, or go take a class somewhere which is difficult as I am in the middle of no where.

THANKS AGAIN.

 
Old November 19th, 2008, 12:51 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

If you are using Windows XP Pro, then look here:

http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=107

Yes, I know, that discusses Access. But SQL Server .mdf files act a *LOT* like Access .mdb files.

And the part you care about is at the end of that FAQ, starting at
WHAT IF THE SECURITY TAB DOESN'T APPEAR IN MY FILE/FOLDER PROPERTIES?

(That section was maybe my first contribution to those FAQs! Wow...hard to believe it's been nearly 8 years now.)
 
Old September 12th, 2013, 04:35 PM
Registered User
 
Join Date: Sep 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Set Read-only attribute of folder

My files AdventureWorks_log.ldf and AdventureWorks_Data.mdf both had their "Read-only" attribute unchecked, but the folder they were in:

C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\

Did have its Read-only set. Unchecking that attribute in the parent folder then allowed the DB to be attached.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Attaching Tables!!! NitinJoshi General .NET 3 January 21st, 2005 11:50 PM
Attaching a string to an e-mail woodsaj9019 Classic ASP Basics 2 May 19th, 2004 09:40 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.