簡體   English   中英

無法打開備份設備“ D:\\ Working Projects \\ FullBackUp.BAK”。 操作系統錯誤3(系統找不到指定的路徑。)

[英]Cannot open backup device 'D:\Working Projects\FullBackUp.BAK'. Operating system error 3(The system cannot find the path specified.)

這個問題在Stackoverflow中得到了很多回答,但是我沒有為我的項目找到合適的解決方案。

讓我先向您展示我的代碼:

namespace ConsoleDBManagement
{
    class Program
    {
        static void Main(string[] args)
        {
            //Metioned here your database name
            string dbname = "newDb";
            SqlConnection sqlcon = new SqlConnection();
            SqlCommand sqlcmd = new SqlCommand();
            SqlDataAdapter da = new SqlDataAdapter();
            DataTable dt = new DataTable();

            sqlcon.ConnectionString = @"Server=ABC-PC\SQLEXPRESS;database=" + dbname + ";uid=dran;pwd=sri;";

            //Enter destination directory where backup file stored
            string destdir = "D:\\Working Projects";

            //Check that directory already there otherwise create 
            if (!System.IO.Directory.Exists(destdir))
            {
               System.IO.Directory.CreateDirectory("D:\\Working Projects");
            }
            try
            {
                //Open connection
                sqlcon.Open();
                //query to take backup database
                //System.IO.File.Create("D:\\Working Projects\\FullBackUp.BAK");

                sqlcmd = new SqlCommand("backup database newDb to disk='" + destdir + "\\FullBackUp.BAK'", sqlcon);
                sqlcmd.ExecuteNonQuery();
                //Close connection
                sqlcon.Close();
                //Response.Write("Backup database successfully");
            }
            catch (Exception ex)
            {
                //Response.Write("Error During backup database!");
            }
        }
    }
}

查詢執行時出現異常。

無法打開備份設備“ D:\\ Working Projects \\ FullBackUp.BAK”。 操作系統錯誤3(系統找不到指定的路徑。)。

BACKUP DATABASE異常終止。

請給我您的建議。

當使用SQL身份驗證登錄名運行備份和/或其他與外部文件相關的命令時,Windows安全上下文就是SQL Service的上下文。

您的問題與“ 備份權限”重復。 授予對SQL Service帳戶/組的許可權,或者使用對路徑具有許可權的Windows身份驗證登錄名運行備份。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM