我正在尝试使用以下方法制作备份文件:
SqlConnection con = new SqlConnection(connection.ConnectionString);
string fname = ofd.FileName + DateTime.Now.ToString("ddMMyyyy") + " - " +
DateTime.Now.ToString("ss-mm-hh");
con.Open();
SqlCommand cmd = new SqlCommand(@"backup database [" + System.Windows.Forms.Application.StartupPath + "\\ManageArtsDB.mdf] to disk ='" + fname + ".bak'with init,stats=10", con);
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("Backup database was successfull", "Back", MessageBoxButtons.OK, MessageBoxIcon.Information);
我得到的错误:System.Data.SqlClient.SqlException:" Database" ' C:\用户\哈立德\桌面\ ManageTrainingArtsF \ ManageTrainingArts \ BIN \调试\ ManageArtsDB.mdf' 不存在。确保正确输入名称。
数据库ManageArtsDB.mdf存在:(但它说它不是!