.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Not able to attach or restore northwind.mdf and northwind.ldf files

Posted By:      Posted Date: October 12, 2010    Points: 0   Category :Sql Server


I downloaded nothwind.mdf and nothwind.ldf  files from the net.when I try to attach any of these files, i am getting the error as "Unable to open the physical file "d:\northwind.mdf".Operating system error5. 5 Access is denied.

Can you please help me to resolve this issue?

View Complete Post

More Related Resource Links

Windows 7 x64, SQL Express 2008 - Problems attach Northwind database

I've attached Northwind many times before, but seem to be unable to do so in Windows 7. I tried attaching from Visual Studio, using osql, and finally (after many hours) installed SQL Express 2008 / SQL Management Express 2008. All methods failed. The last failure (using SME 2008 Attach Databases) is sometimes:

Unable to open the physical file "C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\northwnd.mdf". Operating system error 2: "2(failed to retrieve text for this error. Reason: 15105)". (.Net SqlClient Data Provider)

and other times:

Database 'Northwind' cannot be upgraded because it is read-only or has read-only files. Make the database or files writeable, and rerun recovery. (Microsoft SQL Server, Error: 3415)

I have, of course, verified countless times that the files are NOT read-only.

Could any please explain what could be happening here? All suggestions much appreciated.

many thanks,


Northwind POCO

You cannot vote on your own post

I am trying to create a POCO with EF4 for Northwind db. I am running into problem where the table name Order Details has a space.
If i create a POCO Class OrderDetails it throws exception saying  System.Data.SqlClient.SqlException: Invalid object name 'dbo.OrderDetails'.

public class OrderDetail

    public int OrderID { get; set; }

    public Order Order { get; set; }

    public Product Product { get; set; }

    public double UnitPrice { get; set; }

    public int Quantity { get; set; }

    public int Discount { get; set; }


Master/Detail with Northwind (SSMA) and ASP.NET

I'm trying this example: http://www.asp.net/data-access/tutorials/master-detail-filtering-with-a-dropdownlist-cs I got it to work before, like 6-months ago.  I'm coming back to this now and I can't seem to get the example working. Do I need to create a query in SSMS and then set up my Master/Detail views off of that?  It seems like the GridView is NOT linked to the DropDownList and it seems like there is no way to link the two Objects.  Any ideas as to what I could be doing wrong? Thanks everyone!!

How to attach distribution database files

Hi  i am new to sql server. when i am exploring replication concepts, i did a small mistake i.e. i have deleted distribution database.after that i realised and try to create a new one but it still points to the old database named as "distribution" which is not available. i didnt take the backup of the database before dropping. But i have mdf and ldf files of the distribution database. so can i use the sp_attach method to add the  mdf and ldf files? or any other way to fix this issue? please help me on resolving this issue Thanks, Rock  

Wanted northwind sql server 2008 samples


Hi i m looking for northwind 2008 sample database. But i m unable to get the link. All links are for 2000 samples. Please help

Try to connect Northwind database.


Hi I have Northwind database for access, Nwind.mdb.

The default user is "Admin", it is inconvient for me while I debug code. I always got login user failed error. How can I deal with it? Change user?

 Private NorthwindConnection As New SqlConnection _
  ("Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Nwind.mdb;Initial Catalog=Northwind;Integrated Security=True")


Restore using TSQL, how to determine the files to move/overwrite


There might be an easier way to perform it, if so, please advise.  I am looking for a scriptable solution (preferably TSQL).

I want to code a tsql procedure to restore a database from a backup file (.bak).  The procedure must allow to restore a backup from a database to a different database.

When performing it through the SSMS interface, I see all the files in the .bak file.  From there, I can associate the files in the backup to the appropriate files in my destination database.  when generating TSQL, this translates to MOVE statements for the files.

Can I translate the whole process in TSQL?  In order to know how to map my files, I must first gather the information on which files are present in my bak file.  Can one read the definition of the files contained in a backup file before performing the restore.  Preferably using TSQL?

Attach files in anonymous mode



how can i attach files to sharepoint list in anonymous mode.

I want to attach a file to sharepoint list in anonymous mod but ask me a username and password. please help me to attach files without entering username and password.


How to implement DAL for Cross Tables (e.g. Northwind Orders & OrderDetails)


Microsoft has two very helpful articles on DAL (Creating a Data Access Layer) &

BLL (Creating a Business Logic Layer) but they are Incomplete as the does not cover all the Tables.

The most Important tables in Northwind db are Orders & OrderDetails. Both the articles have nothing about them.

Can any one provide any info. on them ?

How to Deploy MOSS Site Collection using backup/restore with DB attach

Can anyone give pointers on Deploying Moss Sites from Development Environment to Production Envirnment Using backup/restore with DB attach?? TIA
Thanks, Devi Prasad M

NorthWind - Edit Invoice


if i edit any Invoice value,  an exception is thrown -anyone know/translate what is going on?

Unable to update the EntitySet 'Invoices' because it has a DefiningQuery and no <UpdateFunction> element exists in the <ModificationFunctionMapping> element to support the current operation.

sp_send_dbmail can't attach files larger than 2MB


I use [sp_send_dbmail] to send a query result as an xml attachment. When I first started using sp_send_dbmail, my attachments were small XML files and they were delivered correctly and I was happy with it; those files were like 1MB in size.

However, it wasn't that easy at first too. sp_send_dbmail takes lots of arguments and one of them is query_result_width which is a number between 10 and 32767. When you use sp_send_dbmail to send xml attachments, it removes the CR/LF characters at the end of xml lines and turn the whole xml attachment into a single line file; then it will cut the line into 32767 character lines and it doesn't care where is it going to cut the line and you'll end up with a corrupt xml attachment which needs to be edited manually before it gets open in the Microsoft Excel...

I solved that problem by casting the resulting xml into nvarchar(max) and replacing "/>" with "/>CRLF" inside that nvarchar string to avoid those nasty line-breaks.

Now I have another problem. sp_send_dbmail will truncate my xml attachments in exactly 2,097,156 bytes...

I think it's originating from that nvarchar(max) casting. Does anyone know anything of a workaround to this?

This is what I use to send emails:

DECLARE @MailProfile	sysname;

Hard drive crashed - no backup - Files saved, cannot attach sql db



the people called me in their firm because server Won't boot-up (SQL 2000).

I checked it and it was hard drive failure. Manage to get DB data from HD, i wanted to put it on SQL 2005 on new machine.

I successfully attached 5 databases, they are working now, but have problem with 6th. When i trying to attach it get the error;

Server Name: PROMET
Error Number: 9004
Severity: 21
State: 1
Line Number: 1

.mdf file has 1.3 gigs and .ldf 6.1 gig

I searching trough the forums all day, and i cannot find working answer...

Please help me, i can provide additional information if needed.

creating Employee Dim table in northwind


would someone help with here please...

I'm creating an Employee dim table combining employee, EmployeeTerritories, Terriritories, and Region tables. I'm my SSIS OLE DB Destination, i get an error "Failure inserting into read-only EmployeeID" yet my table has no constraints at all.

Thank you people,



How can i retrieve declared product details from northwind with linqdatasource


Hello Guys,

I wan to retrieve spesific data from northwind and list in my compare page. 

in the first page i used gridview with checkboxes. all selected values get with session and then

send to my second page. I can display this values in the page but how can i retrieve all product details from my northwind db i dont know. 

here is my second page code behind. 

Imports System.Data.Linq
Imports System.Data.Linq.Mapping
Imports System.Windows.Forms
Partial Class Cart
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim retProductIDs As List(Of String) = CType(Session("ProductIDs"), List(Of String))
        For Each Str As String In retProductIDs
            Dim str1 As String
            str1 = Str.ToString


    End Sub

and aspx page

    <asp:LinqDataSource ID="LinqDataSource1" runat="server" 
        ContextTypeName="DataClassesDataContext" EntityTypeName="" 
        Select="new (ProductID, ProductName, SupplierID, CategoryID)" 

How to attach files in vb.net


Hi everybody,

I have created an asp.net form in vb.net that sends an activation email after it is filled out and I was wondering how to attach a file(s) to the activation email sent out after the form is submitted.

The function I believe to use after the 'mail.body' portion is:

Dim attachment as New MailAttachment(Server.MapPath("test.txt"))



The portion that is confusing me is what parts above need to be filled in with an actual value. Also, do I need to store the files in a location such as an FTP client or db (at the moment they are on my hardrive).



Restore Files.


Hi Everyone,

I have a database say DB1 having 2 data files and 1 log Files.

My objective is to restore a file of a DB1 using the backup ( Only that specified file will be backed up and restored to another database).

For that what I did ,

1. backed up the file (say mdf)  using file and filegroup option.

2. tried to restore the file in another database DB2, When I did this I got an error that File 2 was not backed up.

Please advise how to accomplish this task.


Thanks in advance



Ranjith Kumar

Ranjith Kumar Mohandas
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend