How to backup a SQL Server 2014 Express Localdb (.mdf) file programmatically

前端 未结 2 1292
一向
一向 2020-12-20 06:09

I have simple Windows application which uses SQL Server 2014 LocalDB (.mdf file).

And I want that whenever users click exit button, my application autom

2条回答
  •  囚心锁ツ
    2020-12-20 06:42

    I finally solved after many trial and analysis. For someone who is looking for solutions, I share mine as below.

    It seems there's fewer people are developing with MS SQL Localdb than other databases.

    The name of database doesn't have to include extension like .mdf and the equal sign= has to be together as DISK=

    string backupdb = string.Format(@"BACKUP DATABASE greendb_{0} TO DISK='c:\Green_Backup\greendb_{0}.bak'", personID);

提交回复
热议问题