Solved

Trouble Attaching MDF file From Client

Posted on 2002-06-05
9
604 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
  • 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 142

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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
LVL 142

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 142

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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how the fundamental information of how to create a table.

773 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