Solved

Trouble Attaching MDF file From Client

Posted on 2002-06-05
9
616 Views
Last Modified: 2008-02-26
I have a utility written in Delphi which uses Sql Dmo to talk to Sql Server. I have a local installation of Sql Server and there is also a Server installation.

The utility prompts the user for a Database Name and file location (for the mdf). If the location doesn't exist it creates it. Then it copies an empty version of our application's MDF file to the location and attempts to attach it to Sql Server using the following syntax:

dmo.AttachDBWithSingleFile(edtSqlDBName.Text, sFileLocNew);

edtSqlDBName.Text does contain the Name of the database and sFileLocNew does contain a full path to the mdf file.

When running against my local copy of Sql Server everything works just fine. The file is copied and then attached using the new name.

But when trying the same thing against the server I am able to create the new folder and copy the mdf file, but I get the following error when attempting to attach:

File '\\Labserver\C\Program Files\Kewill\JobBOSS\Databases\TrainSql\TrainSql_data.mdf' is on a network device not supported for database files.

What has gone wrong? I know I can talk to the server version as I have done other things (including detaching, copying and then reattaching databases) with it.

Thanks
0
Comment
Question by:bjames
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 7

Accepted Solution

by:
lozzamoore earned 200 total points
ID: 7056380
Make sure you are referencing the sFileLocNew parameter as a local path relative to the SQL server you are running the command from.

SQL server will only let you attach a database that is local to it, and the command is obviously checking for a UNC path, even if the UNC path corresponds to a local path.

Hope that makes sense and helps.

Cheers
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 7056385
The problem is that you try to attach a file that is actually local, but the path is like it were remote.

You must change the path that you supply from
\Labserver\C\Program Files\Kewill\JobBOSS\Databases\TrainSql\TrainSql_data.mdf
to this:
C:\Program Files\Kewill\JobBOSS\Databases\TrainSql\TrainSql_data.mdf

CHeers
0
 

Author Comment

by:bjames
ID: 7056396
I'm in a bit of a bind now. You both answered at virtually the same time with virtually the same answer which IS the solution. I'm not sure what the protocol is here.

According to the timestamps Iozzamoore is about two minutes earlier than angellll. Going on a 'first come first served' basis that means Iozzamoore should get the points. But since both have given me the solution does this fit with Experts Exchange protocol? I want to do the right thing.

Thanks
0
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 7056554
You can of course accept the first one, or if you prefer, ask the Community support (using a 0-point question there) to split the points. DOn't forget then to post a link to your question so they know which q you want the split.
CHeers
0
 
LVL 7

Expert Comment

by:lozzamoore
ID: 7056608
The points should obviously go to me! ;-)
Seriously though, I am happy to split.
Cheers,
0
 

Author Comment

by:bjames
ID: 7056630
I posted to the community and nfroio said that this has happened to him/her and that generally points are awarded based on the earliest correct answer by timestamp. So that is how I will resolve my conflict.

Thanks to both angellll and Iozzamoore for the help.

Thanks
0
 

Author Comment

by:bjames
ID: 7056632
I suspected this was probably the case, but I couldn't find anything in the help files about it.

Thanks
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 7056803
Glad we could help.
CHeers
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 7056868
Perfect solution here.  Since both experts were concurrently typing (one slower than the other ;), I have also posted a separate question for angellII here (not at your expense, but from my points).  It seems most fair.
Points for angelIII -> http://www.experts-exchange.com/jsp/qShow.jsp?qid=20308197

:) Moondancer - EE Moderator
0

Featured Post

What Is Blockchain Technology?

Blockchain is a technology that underpins the success of Bitcoin and other digital currencies, but it has uses far beyond finance. Learn how blockchain works and why it is proving disruptive to other areas of IT.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question