更新时间:2022-11-27 21:03:54
比你想象的要复杂得多!请参阅此处:使用C#备份SQL数据库 [ ^ ]
Slightly more complex than you think! See here: Backing up an SQL Database in C#[^]
尝试在数据库名称周围加上方括号:
Try to put square brackets around the database name:
BACKUP DATABASE [Ast-db] TO DISK
string path="D:/filename.bak";
SqlCommand cmd=new SqlCommand("backup database dbnameto disk='"+path+"'",con);
int a=cmd.ExecuteNonQuery();