如题。找个易懂的。。比如我的数据库名是CTGL。。要如何备份。又如何恢复!备份的文件的路径要在当前项目的文件夹里面。请各位大虾帮忙;
解决方案 »
- c# 局域网连接ACCESS数据库如何写连接字符串?
- winform comboBox??急~~
- c# dropdownlist绑定gridview的问题
- VS2005中的提示功能
- 我见过最牛X的面试者!!!
- 简单sql查询,高分求助(层次化查询)
- 打包卸载的问题
- 求一算法
- C#实现一个窗口调用另外一个窗口
- C#中使用SQL Server分布式管理对象sqldmo.dll出错:"接口SQLDMO.Namelist 的 QueryInterface 失败"。示例http://www.ccw.com.cn/htm/cente
- 新手求解..........劳驾(看对不)绝对回评.......
- 网站做了伪静态以后,为什么IIS日志里显示爬虫还是抓的.asp?XX=1这样的格式?
{
string strg = Application.StartupPath.ToString();
strg = strg.Substring(0, strg.LastIndexOf("\\"));
strg = strg.Substring(0, strg.LastIndexOf("\\"));
strg += @"\Data";
string sqltxt = @"BACKUP DATABASE ctgl TO ctgl_bf ='" + strg + "\\" + textBox1.Text + ".bak" + "'";
SqlConnection con = new SqlConnection(@"server=.;database=CTGL;Integrated Security=sspi;");
con.Open();
SqlCommand cmd = new SqlCommand(sqltxt, con);
cmd.ExecuteNonQuery();
con.Close();
if (MessageBox.Show("备份成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) == DialogResult.OK)
{
this.Close();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}这是我参考别的代码写出来的。但是不行
弹出个窗体,显示ctal_bf不是可以识别的device type
话说你在使用的数据库的程序中 貌似是无法备份和恢复 我是做的单独程序来做备份和恢复的
原理 和楼上那个一样 就是sql语句
{
string[] parmsName = { "@dbname", "@bkpath" };
object[] parmsValue = { System.Configuration.ConfigurationManager.AppSettings["DB"].ToString(), Server.MapPath("../Data/") };
Sys_Unit unit = SysUnitBLL.GetModelByProc(parmsName, parmsValue);//调用备份存储过程
if (unit != null)
{
Response.AppendHeader("Content-Disposition", "attachment;filename=" +HttpUtility.UrlEncode(unit.FName) + "");
Response.ContentType = "application/ms-BAK";
Response.WriteFile("" + Server.MapPath("../Data/") + unit.FName + "");
Response.End();
}
}