复制 mdf 文件并在运行时使用它
复制 mdf 文件(及其日志文件)后,我尝试插入数据。 我收到以下消息:
“尝试附加文件 [fileName].mdf 的自动命名数据库失败。存在同名的数据库,或无法打开指定的文件,或者它位于 UNC 共享上。
当我复制文件手册一切正常。 File.Copy 保留文件的顺序是否正确?
After I copy mdf file (and his log file) I tries to Insert data.
I receive the following message:
"An attempt to attach an auto-named database for file [fileName].mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
When I copied the file manual everything worked normally.
Is it correct the order File.Copy leaves the file engaged?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
确保复制 mdf 文件时没有打开该文件的连接。这可能与两个副本只有一个锁定文件有关。
Make sure you don't have a connection open to the mdf file when you copy it. This might be related to there being only one lock file for the two copies.
解决方案要简单得多。
我忘记关闭文件了
The solution was much more simple.
I forgot to close the file