路径位置Vb.net中的错误 [英] Error in Path Location Vb.net

查看:78
本文介绍了路径位置Vb.net中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi All



错误:



访问路径''C:\Program Files \ Microsoft SQL Server \ MSSQL10.SQLEXPRESS \ MSSQL \DATA \ SMD.mdf''被拒绝。



我使用的代码:





system.IO.File.Copy((C:\Program Files \ Microsoft SQL Server \ MSSQL10.SQLEXPRESS \ MSSQL \ DATA \ SMD.mdf),newname)



请告诉我..如何制作路径

hi All

Error:

Access to the path ''C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\SMD.mdf'' is denied.

I Used Code:


system.IO.File.Copy(("C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\SMD.mdf"), newname)

Please tell me.. how to make path

推荐答案

您无法读取该文件,因为它仍然由SQL Server引擎附加。在触摸它之前,您必须在SQL Server中取消附加数据库。



实际上,进行备份不是应用程序代码的操作。这通常作为SQL Server中的计划任务完成。 DBA通常会对此进行设置。
You can''t read the file because it''s still attached by the SQL Server engine. You have to unattach the database in SQL Server before you can touch it.

Really, making a backup is not an operation for your application code. This is normally done as a scheduled task in SQL Server. A DBA usually sets this up.


您无权访问当前用户的文件夹 - 您需要模拟具有访问权限的用户,或更改权限。夹。另一件需要考虑的事情是,因为它位于SQL DATA文件夹中,所以当您尝试复制该文件时,SQL很可能正在使用该文件,并且由于该文件正在使用,该副本将失败。



如果这是一个SQL数据库,为什么不用SQL本身备份呢?这可能会有所帮助:在C#中备份SQL数据库 [ ^ ](它在C#中,但代码shoudl很容易翻译。
You do not have access to the folder with your current user - you either need to impersonate a user who does have access permissions, or change the permissions on the folder. The other thing to consider is that since this is in an SQL DATA folder, there is a good chance that the file is going to be in use by SQL when you try to copy it, and the copy will fail because the file is in use.

If this is an SQL database, why not back it up using SQL itself instead? This might help: Backing up an SQL Database in C#[^] (it''s in C#, but teh code shoudl translate very easily.


这篇关于路径位置Vb.net中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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