locked
Northwind.mdf. "You don't have permission to open this file. Contact the file owner or the administrator to obtain permission"

    Question

  • <!-- @page { margin: 0.79in } P { margin-bottom: 0.08in } -->Hi,


    I want to add a connection in Visual Studio C#2008 Express to MS SQL Server 2005 Express on the same Windows Vista Home Premium PC. These are the current steps I am following in C# Visual Studio
    1) Choose Tools->Connect to Database
    2) Select Microsoft SQL Server Database File (SQLClient)
    3) On the Text box titled "Database File Name (New or Existing), I have tried to select browse to locate an existing database file norwinds.mdf, and also a new one created with SQL Server 2005 Express thru SQL Server Management Studio. 

    But i get error message "You don't have permission to open this file. Contact the file owner or the administrator to obtain permission"

    Question #1. What else I need to do since I am part of the administrator group, and the file properties has alll the permisions for the administrators including (my username).?

    4) On another test; On the Text Box of previous step 3) if by the contrary, if I select a new database file for example "new.mdf", the system created it for me nicely, and the database explorer is filled with the SQL Database Structures.

    Then, I wanted to see the file "new.mdf" database from the Visual SQL Server Management Studio, but it only let me see the database it SQL Server Studio created.

    Question #2. Is this the way it is suppose to work? The SQL Server 2005 Express takes cares of those database created by SQL Management Tool, but ther is no connection to other applications like a Visual C# 2008 application. And the Visual C# 2008 new SQL Database file created, cannot be opened by a SQL Server 2005.

    Please be kind, the last time I did database programming was years ago. Need to get up to speed with modern tools and I am stuck with these trivial details.

    Thanks,
    Jose

    Friday, September 04, 2009 2:50 AM

Answers

  • You may have to re-install, or at least make sure the apps are up to date with service packs.
    Also, make sure the SQL servics are running.

    I have found that it is best to install SQL Express first, then run the application at least once.  It seems to perform some final initializations the first time it runs.  Run it prior to doing any updates.  Do the same with C# Express.  Install, run it at least once, and then update it.

    Rudedog  =8^D

    Mark the best replies as answers. "Fooling computers since 1971."
    • Marked as answer by jamald Friday, September 11, 2009 2:32 AM
    Tuesday, September 08, 2009 2:03 PM
  • Hi,

    The thread may help.
    http://social.msdn.microsoft.com/Forums/en-US/sqlexpress/thread/42707a11-d691-4a4c-bfc7-a9243a6e7168/

    Harry
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by jamald Friday, September 11, 2009 2:33 AM
    Thursday, September 10, 2009 7:39 AM

All replies

  • Let's start by making sure that you do indeed have the appropriate permissions at the filesystem level. For the existing database, where you get the error message, are you able to double click the file in Windows Explorer - outside of Visual Studio - and have the file open in Access? Or does that also give you an error message?
    Tuesday, September 08, 2009 12:21 PM
  • You may have to re-install, or at least make sure the apps are up to date with service packs.
    Also, make sure the SQL servics are running.

    I have found that it is best to install SQL Express first, then run the application at least once.  It seems to perform some final initializations the first time it runs.  Run it prior to doing any updates.  Do the same with C# Express.  Install, run it at least once, and then update it.

    Rudedog  =8^D

    Mark the best replies as answers. "Fooling computers since 1971."
    • Marked as answer by jamald Friday, September 11, 2009 2:32 AM
    Tuesday, September 08, 2009 2:03 PM
  • Hi,

    The thread may help.
    http://social.msdn.microsoft.com/Forums/en-US/sqlexpress/thread/42707a11-d691-4a4c-bfc7-a9243a6e7168/

    Harry
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by jamald Friday, September 11, 2009 2:33 AM
    Thursday, September 10, 2009 7:39 AM
  • Jeff, Just to answer, that only have Access 2007 and the file format for SQL Files was not available.

    Harry, it helped run C# Studio with Run As Administrator. I'm still looking to check other options recommended for the use of the same SQL file with C# and with MS SQL Studio.

    Rudedog, I think that some magic happened when I created a new mdf file in C# Studio. There were some Demo database files located in my folders, that did  not open before, and now I am connecting them!!! Thanks for the clarification.

    Friday, September 11, 2009 2:26 AM
  • And be aware that the Connection Wizards in the Express Editions do not connect to SQL Server instances.
    You will only be able to connect to database files using the Wizards.

    You can connect to a server instance programmatically by modifying the connection string .
    Make sure that you specify a database that is attached to the server instance.

    Also, SQL Express has remote connections disabled by default.

    Rudedog  =8^D

    Mark the best replies as answers. "Fooling computers since 1971."
    Friday, September 11, 2009 3:20 PM
  • Wao, Wao, Wao! Thanks a lot!!!

    Now things are falling in place again. After so many unsuccessful atempts, with at least the SQL Client File working, the connetion to a SQL Server instance turned in a real Lost Cause for me.

    Thanks for saving me 2 weeks of hitting my forehead against the wall, while looking for a workaround. Guys like you are an inspiration to rusky programmers like me.

    Thanks again.

    Kind regards,
    Jose
    Tuesday, September 15, 2009 12:47 AM