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);

         }

相关文章:

  • 2021-08-18
  • 2022-01-17
  • 2021-12-11
  • 2021-06-12
猜你喜欢
  • 2021-11-24
  • 2021-12-05
  • 2022-12-23
  • 2022-12-23
  • 2021-08-06
  • 2022-12-23
  • 2021-06-02
相关资源
相似解决方案