Solved

Trouble Attaching MDF file From Client

Posted on 2002-06-05
9
595 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
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…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how the fundamental information of how to create a table.

760 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

20 Experts available now in Live!

Get 1:1 Help Now