Link to home
Start Free TrialLog in
Avatar of ChrisMDrew
ChrisMDrew

asked on

C# Using SMO to copy a SQL Server database under Windows 7

Hi,

I have an application which normally runs against a SQL Server installation on a server but needs to be able to also run in a 'detached' mode whereby it runs against a local SQL Server.

This has been running happily for a while - currently I use SMO and Microsoft.SqlServer.ManagementObjects.Smo.Transfer.TransferData to copy the entire database from the remote SQL Server to a local SQL Server instance.

I have recently upgraded both my main SQL Server and my local PC to Windows 7 and on trying this operation I now get an error of :-

ERROR : errorCode=0 description=Directory lookup for the file "C:\Program Files\Microsoft SQL Server\MSSQL10_50.LIFECHECK\MSSQL\DATA\lifecheckv4.mdf" failed with the operating system error 3(failed to retrieve text for this error. Reason: 15105). helpFile= helpContext=0 idofInterfaceWithError={C81DFC5A-3B22-4DA3-BD3B-10BF861A7F9C}

This is when copying the database from my remote server to my local instance.  I have disabled the Windows Firewall on both PCs just in case that is intefering but am not at a bit of a loss to explain what the problem is.
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ChrisMDrew
ChrisMDrew

ASKER

Thanks for this - the main issue was one which I have hit before and forgot about!  For the code to work the SQL Server instance name must be the same on both the target and source PCs - otherwise the above error is displayed.  I guess it is a 'hole' or bug in the SMO implementation.