如何使用C#复制当前工作的mdf文件 [英] How to copy currently working mdf file using C#

查看:103
本文介绍了如何使用C#复制当前工作的mdf文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想复制mdf文件,这个mdf文件当前在我的应用程序中使用。当我试图复制mdf文件然后它将显示错误当前文件中使用的其他过程我试图处理连接,但这也没有帮助我请帮助我。



我尝试过:



//这里我断开SQL连接

连接。关闭();

SqlConnection.ClearPool(连接);

connection.Dispose();

connection.Dispose();



//这里我试图复制但不成功

System.IO.File.Copy(DownloadmdfPath,UploadmdfPath,true);

解决方案

快速如何使用C#复制mdf文件 - Google搜索 [ ^ ]有很多答案...



虽然不是英文,但他的代码很容易理解并回答你的问题:如何使用c#net复制数据库在sql server中 - YouTube [ ^

I want to copy the mdf file and this mdf file is currently Used in my application. when i am trying to copy mdf file then it will display error currenly file used in other process i have tried to dispose the connection but this also not helpful for me please help me.

What I have tried:

//Here i am Disconnecting the SQL connection
connection.Close();
SqlConnection.ClearPool(connection);
connection.Dispose();
connection.Dispose();

//Here i am trying to copy but not success
System.IO.File.Copy(DownloadmdfPath, UploadmdfPath, true);

解决方案

A quick How to copy mdf file using C# - Google Search[^] has lots of answers...

Whilst not in English, his code is easy to follow and answers your question: How to copy database in sql server using c# net - YouTube[^]


这篇关于如何使用C#复制当前工作的mdf文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆