SQL Server 2008 files always "in use" when trying to access from Visual Studio

  • New, updated installation of Visual Studio 2008 and SQL Server 2008. All patches applied.

    Created db and tables using Management Studio. Can open, view, edit, close all tables.

    In Visual Studio when I try to open use the same db and tables I always get the message that the files are in use.

    I have tried rebooting with no effect.

    Any help appreciated,

    TH

  • Are you trying to manipulate the files directly? If so, then SQL Server is using them, as far as Windows is concerned, and they will always be "in use" if the SQL services are running. What you should be doing, in normal circumstances, is building a database connection, and accessing data through that. Is that what you're doing, or something else?

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • So far all I have tried going to Data on the VS main menu, selecting Add New Data Source, browsing to the .mdf file and selecting that file. I always get an error message telling me that the file is in use. I only have Visula Studio running and nothing else is working with SQL Server. I have tried rebooting to see if any old locks (couldn't be very old since I just created the db) would be dropped. No luck.

    I can always access the db and table using Management Studio and everything is OK and available.

    TH

  • You're trying to open the file. You can't.

    You need to provide a server and instance name as part of the connection string for Visual Studio. It's the same server name and settings as you use in Management Studio.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • What edition of VS2008 are you running? if you are in professional and standard you can only connect to the database through server explorer but if you are in VS2008 Team Database developer and Team Suites you could develop database and objects but I have never run Team Suites 2005/8 without local SQL Server Developer edition so I don't know.

    Kind regards,
    Gift Peddie

  • I use Team System Database Edition. You don't connect to the .mdf/.ldf files with that tool either. You connect to a database through a connection string, or you have a set of database objects stored as SQL scripts.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Grant,

    I think the persom is in SQL Server Express which allows User instance users to connect to the MDF but it must be local so if the person is in Server instance the person cannot connect to the MDF file and the user instance does not include LDF but I could be wrong.

    Kind regards,
    Gift Peddie

  • Ah, different world. I think you're right.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Hi Grant,

    I just guessed because there is no LDF in both posting so I assumed the user in running Express.

    Kind regards,
    Gift Peddie

  • I am using Visual Studio Professional

    Microsoft Visual Studio 2008

    Version 9.0.30729.1 SP

    Microsoft .NET Framework

    Version 3.5 SP1

    Installed Edition: Professional

    Microsoft Visual Basic 2008 91605-140-8228787-60738

    Microsoft Visual Basic 2008

    Microsoft Visual C# 2008 91605-140-8228787-60738

    Microsoft Visual C# 2008

    Microsoft Visual C++ 2008 91605-140-8228787-60738

    Microsoft Visual C++ 2008

    Microsoft Visual Studio 2008 Tools for Office 91605-140-8228787-60738

    Microsoft Visual Studio 2008 Tools for Office

    Microsoft Visual Web Developer 2008 91605-140-8228787-60738

    Microsoft Visual Web Developer 2008

    Crystal Reports AAJ60-G0MSA4K-68000CF

    Crystal Reports Basic for Visual Studio 2008

    Hotfix for Microsoft Visual Studio 2008 Professional Edition - ENU (KB944899) KB944899

    This hotfix is for Microsoft Visual Studio 2008 Professional Edition - ENU.

    If you later install a more recent service pack, this hotfix will be uninstalled automatically.

    For more information, visit http://support.microsoft.com/kb/944899.

    Hotfix for Microsoft Visual Studio 2008 Professional Edition - ENU (KB945282) KB945282

    This hotfix is for Microsoft Visual Studio 2008 Professional Edition - ENU.

    If you later install a more recent service pack, this hotfix will be uninstalled automatically.

    For more information, visit http://support.microsoft.com/kb/945282.

    Hotfix for Microsoft Visual Studio 2008 Professional Edition - ENU (KB946040) KB946040

    This hotfix is for Microsoft Visual Studio 2008 Professional Edition - ENU.

    If you later install a more recent service pack, this hotfix will be uninstalled automatically.

    For more information, visit http://support.microsoft.com/kb/946040.

    Hotfix for Microsoft Visual Studio 2008 Professional Edition - ENU (KB946308) KB946308

    This hotfix is for Microsoft Visual Studio 2008 Professional Edition - ENU.

    If you later install a more recent service pack, this hotfix will be uninstalled automatically.

    For more information, visit http://support.microsoft.com/kb/946308.

    Hotfix for Microsoft Visual Studio 2008 Professional Edition - ENU (KB946344) KB946344

    This hotfix is for Microsoft Visual Studio 2008 Professional Edition - ENU.

    If you later install a more recent service pack, this hotfix will be uninstalled automatically.

    For more information, visit http://support.microsoft.com/kb/946344.

    Hotfix for Microsoft Visual Studio 2008 Professional Edition - ENU (KB946581) KB946581

    This hotfix is for Microsoft Visual Studio 2008 Professional Edition - ENU.

    If you later install a more recent service pack, this hotfix will be uninstalled automatically.

    For more information, visit http://support.microsoft.com/kb/946581.

    Hotfix for Microsoft Visual Studio 2008 Professional Edition - ENU (KB947171) KB947171

    This hotfix is for Microsoft Visual Studio 2008 Professional Edition - ENU.

    If you later install a more recent service pack, this hotfix will be uninstalled automatically.

    For more information, visit http://support.microsoft.com/kb/947171.

    Hotfix for Microsoft Visual Studio 2008 Professional Edition - ENU (KB947173) KB947173

    This hotfix is for Microsoft Visual Studio 2008 Professional Edition - ENU.

    If you later install a more recent service pack, this hotfix will be uninstalled automatically.

    For more information, visit http://support.microsoft.com/kb/947173.

    Hotfix for Microsoft Visual Studio 2008 Professional Edition - ENU (KB947180) KB947180

    This hotfix is for Microsoft Visual Studio 2008 Professional Edition - ENU.

    If you later install a more recent service pack, this hotfix will be uninstalled automatically.

    For more information, visit http://support.microsoft.com/kb/947180.

    Hotfix for Microsoft Visual Studio 2008 Professional Edition - ENU (KB947540) KB947540

    This hotfix is for Microsoft Visual Studio 2008 Professional Edition - ENU.

    If you later install a more recent service pack, this hotfix will be uninstalled automatically.

    For more information, visit http://support.microsoft.com/kb/947540.

    Hotfix for Microsoft Visual Studio 2008 Professional Edition - ENU (KB947789) KB947789

    This hotfix is for Microsoft Visual Studio 2008 Professional Edition - ENU.

    If you later install a more recent service pack, this hotfix will be uninstalled automatically.

    For more information, visit http://support.microsoft.com/kb/947789.

    Hotfix for Microsoft Visual Studio 2008 Professional Edition - ENU (KB948127) KB948127

    This hotfix is for Microsoft Visual Studio 2008 Professional Edition - ENU.

    If you later install a more recent service pack, this hotfix will be uninstalled automatically.

    For more information, visit http://support.microsoft.com/kb/948127.

    Hotfix for Microsoft Visual Studio 2008 Professional Edition - ENU (KB952241) KB952241

    This hotfix is for Microsoft Visual Studio 2008 Professional Edition - ENU.

    If you later install a more recent service pack, this hotfix will be uninstalled automatically.

    For more information, visit http://support.microsoft.com/kb/952241.

    Hotfix for Microsoft Visual Studio 2008 Professional Edition - ENU (KB953256) KB953256

    This hotfix is for Microsoft Visual Studio 2008 Professional Edition - ENU.

    If you later install a more recent service pack, this hotfix will be uninstalled automatically.

    For more information, visit http://support.microsoft.com/kb/953256.

    ReSharper 4.5 Full Edition build 4.5.1231.7 on 2009-04-08T16:10:26

    ReSharper add-in for Microsoft Visual Studio. For more information about ReSharper, see the ReSharper website at http://www.jetbrains.com/resharper. Copyright © 2003–2009 JetBrains, Inc

    I am using SQL Server Workgroup,

    Microsoft SQL Server Management Studio10.0.2520.0

    Microsoft Analysis Services Client Tools10.0.1600.22

    Microsoft Data Access Components (MDAC)6.1.7000.0

    Microsoft MSXML3.0 5.0 6.0

    Microsoft Internet Explorer8.0.7000.0

    Microsoft .NET Framework2.0.50727.3521

    Operating System6.1.7000

    As I said these are fresh installations. This is the first try at using them together.

    Thanks,

    TH

  • Because you are not using SQL Server 2008 Express - you do not have the option of attaching a user defined database. You have a server running that controls access to the database files - and you need to use that server to access the database.

    To do that, you need to create a connection to the database server. This is not like trying to open an Access database. To create the connection, you specify the SQL Server Instance hosting the database and the database name.

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

  • OK, Thanks

    I got it working.

    TH

  • In the tools menu you could also connect to the database through Server Explorer, in Professional you could save your stored procs to VSS from the Server Explorer. No it is not automatic but I have done it for the day your SQL Server is out.

    Kind regards,
    Gift Peddie

Viewing 13 posts - 1 through 12 (of 12 total)

You must be logged in to reply to this topic. Login to reply