Solved

Trouble Attaching MDF file From Client

Posted on 2002-06-05
9
600 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
 
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
Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

 
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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Query stumper 3 37
Microsoft Azure SQL - create a read only user 2 14
Help Extract Specific in SQL 8 25
Update SQL to SP1 on SCCM server 7 13
I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

896 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now