I am开发者_C百科 trying to move databases from one SQL server to another.I am doing this through a Console written in C#. The methodology is a follows. I first detach the database, move the data and log files to the new location and then attach the files from there. However after I detach the file, I am not able to copy the data and log files. The error that I get is :'device is not ready'. I am using network paths for both the source and destination. I'm using the File.Copy() to move the files and I have permissions to create files in the respective folders
At a hunch, 'device is not ready' is not an C# exception generated by the File Copy command. The possible exceptions are;
UnauthorizedAccessException, ArgumentException, ArgumentNullException,
PathTooLongException, DirectoryNotFoundException, FileNotFoundException,
IOException, NotSupportedException
So this 'error' could possibly be something which generated internally, as per the other comments, more information is needed. In order to debug this problem I suggest the following
- Place a breakpoint in your code where 'device is not ready' text string is present in your code
- Check both paths in your code are valid paths
- Is your program is built to handle UNC paths or file paths?
- Possibly an exception is being silently caught, but you'll need to debug to find this out
- If your trying to move databases, have you stopped the Windows Service instance associated with the database? Type services.msc from the run command, then scroll to SQL Server (your SQL instance name) then stop the service from there. That would unlock the database file.
Good luck.
精彩评论