SqlServer2000数据库备份

 
 

private void Button4_Click(object sender, System.EventArgs e)

         {

              string dataName=System.DateTime.Now.ToString();//获取当前时间

              dataName=dataName.Replace("-","");//去掉'-'

              dataName=dataName.Replace(" ","");//去掉空格

              dataName=this.txtDataName.Text+dataName.Replace(":","");//去掉':'

              string logicFile=this.txtDataName.Text+dataName;//逻辑名称-输入名称+时间

              string dataPath;

              string tempPath;

              tempPath=this.txtPath.Text.Trim();

              System.IO.DirectoryInfo dicinfo=new System.IO.DirectoryInfo(tempPath);//判断是否存在

              if(!dicinfo.Exists)

              {

                   dataPath=Server.MapPath("Admin/DataBack/")+dataName+".dat";

              }

              else

              {

                   dataPath=tempPath;

              }

              string str=" EXEC sp_addumpdevice 'disk', '"+logicFile+"','"+dataPath+"'";//建立文件组

              string str2="BACKUP DATABASE qiking TO "+logicFile;//执行备份

              DAL.SQLHelper.ExecuteNonQuery(DAL.SQLHelper.CONN_STRING,System.Data.CommandType.Text,str);

                       DAL.SQLHelper.ExecuteNonQuery(DAL.SQLHelper.CONN_STRING,System.Data.CommandType.Text,str2);

         }

人的一生应该这样度过:当他回首往事的时候,不会因为虚度年华而悔恨,也不会因为碌碌无为而羞愧。
原文地址:https://www.cnblogs.com/htht66/p/889748.html