Connection problem to SQL Server 2005

  • Through the Database Explorer of VB2005 express i have make a connection to a local mdf file. So far so good.. The problem i deal with, is when i am trying to have a connection with UNC path.. The below error appears..

    The file “\\dpt01\HALSQL\MSSQL\Data\test.mdf” is on a network path that is not supported for database files. An attempt to attach an auto-named database for file \\dpt01\HALSQL\MSSQL\Data\test.mdf failed. A database with the same name exists, specified file cannot be opened, or it is located on UNC share.

    As i understand the UNC path is not supported.. How am i going to have a connection to the SQL Server..;

    Any idea..;

    Thank you

  • You cannot connect to the server this way. The mdf file is locked explicitly by the SQL Server.

    When you connect to the database, specify the server name, log on details, and instead of specifying the database file just select the database name.

    Andras


    Andras Belokosztolszki, MCPD, PhD
    GoldenGate Software

  • Andras thank you for your reply.. I cant figure out the way you are describing me to connet to Sql..

  • neoklis (10/3/2007)


    Andras thank you for your reply.. I cant figure out the way you are describing me to connet to Sql..

    SQL Server is not simply a file on a machine somewhere. In fact, a database in SQL Server can be composed of a whole series of files, spread across multiple disks, etc. Instead, SQL Server is a service running on a machine, usually a server class machine, that has an some type of network address, an instance name and possibly a port number needed to connect to it. For example, to connect to one instance on one of my machines, the connection is to FRITCHEYG1XP\GF2005. On that SQL Server instance, multiple databases exist with multiple files defining them.

    You're a bit off track here. Take a look at a few of these links and see if they help:

    This is the basic documentation on connecting:

    http://msdn2.microsoft.com/en-us/library/ms190944.aspx

    This is a tutorial specifically aimed at what you're trying to do:

    http://msdn2.microsoft.com/en-us/library/ms345343.aspx

    "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

  • Thank you Grant.. I 'll take a look at your links..

  • with SQL2005 Express Edition, you can "in line" attach a mdf-file only on the local instance !

    Attach a database file on connect to a local SQL Server Express instance

    Driver={SQL Native Client};Server=.\SQLExpress;AttachDbFilename=c:\yourpath\mydbfile.mdf; Database=dbname;Trusted_Connection=Yes;

    I don't think you can use this with UNC, maybe you can if your SQL2005 express edition service account is a domain account which has the authority to access (read/write) to that path and file.

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

  • I am trying to connect to SQL Server 2000 (not to Sql Server Express) with Visual Basic 2005 Express Edition...

  • Oops :blush: ... this thread is in the SQL2005 forum ...

    the methode I explained is not possible with SQL2000.

    So you connect to a sqlserver instance and specify a dbname,.. .

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

  • Not sure this has been brought up yet - but you need to enable Trace Flag 1807 before tying in to network DB files (usually a very bad idea anyway, but sometimes necessary in a pinch).

    Take a look here: http://support.microsoft.com/kb/304261

    And - agreed on not being able to inline in 2000

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

  • If you are connecting to 2000, and the database you are trying to connect to is online, as mentioned you will not be able to access the mdf file.

    In the wizard/dialog where you specify the file name, isn't there a radiobutton and an alternative to select a database instead of attaching a database file? Choosing this would allow you to access the live database the same way, but you will not need to care about the filepaths.

    Reading the documents Grant suggested is certainly a good idea 🙂

    Andras


    Andras Belokosztolszki, MCPD, PhD
    GoldenGate Software

  • The links I supplied are for 2005 (it's that kind of forum), but the concepts should be the same.

    "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

  • I 've noticed it Grand..

    thanks..

  • A little late to the game, but why are you trying to attach the MDF across the network? Maybe we have a better alternative.

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

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