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