protected void Page_Load(object sender, EventArgs e) { UILogic.ClearCache(); VPUserInfo userinfo = UILogic.getSession() as VPUserInfo;  ,asp.net(c#)如何连接和访问mysql; if (userinfo == null) { //Response.Write("<mce:script type="text/javascript"><!-- top.location.href='~/../login.aspx' // --></mce:script>"); } else { //if (!Page.IsPostBack) //{ System.IO.Directory.CreateDirectory("C://Program Files//MySQL//MySQL Server 5.0//data//vpdata");//在服务器mysql中创立vpdata数据库 //} } } protected void Backup_Click(object sender, ImageClickEventArgs e) { try { //string filename = DateTime.Now.ToString().Replace("-", "").Replace(":", "").Replace(" ", ""); string filePath = "D://web//App_Data"; string fileName = filePath + "//vpdata.sql";//备份的文件名称跟路径 //断定目录是否存在 if (!System.IO.File.Exists(fileName)) { System.IO.Directory.CreateDirectory(filePath); } //构建执行的命令 String command = string.Format("mysqldump --quick --host=localhost --default-character-set=latin1 --lock-all-tables --port=3306 --user=root --password=123456 --databases vpdata -R >D://web//App_Data//{0}.sql", "vpdata"); //获取mysqldump.exe所在门路  ,asp.net 如何对Session实现倒计时; String appDirecroty = @"C:/Program Files/MySQL/MySQL Server 5.0/bin/"; StartCmd(appDirecroty, command); ScriptManager.RegisterClientScriptBlock(Backup, GetType(), "yes", "alert('数据库已胜利备份到D://web//App_Data//Vpdata文件中')", true); } catch (Exception ex) { ScriptManager.RegisterClientScriptBlock(Backup, GetType(), "no", "alert('数据库备份失败!')", true); } } protected void Restore_Click(object sender, ImageClickEventArgs e) { try  ,asp 中如何连接页面; { //构建执行的命令 String command = string.Format("mysql --host=192.168.1.10 --default-character-set=latin1 --port=3306 --user=root --password=123456 vpdata <D://web//App_Data//{0}.sql", "vpdata");  ,ASF格式音频文件如何在MP3播放器上播放; //获取mysql.exe所在路径 String appDirecroty = @"C:/Program Files/MySQL/MySQL Server 5.0/bin/"; StartCmd(appDirecroty, command); ScriptManager.RegisterClientScriptBlock(Restore, GetType(), "yes", "alert('服务器数据库还原成功!')", true); } catch (Exception ex) { ScriptManager.RegisterClientScriptBlock(Restore, GetType(), "no", "alert('数据库还原失败!')", true); } } /// <summary> /// 执行Cmd命令 /// <,ARP病毒如何在计算机中查找;/summary> /// <param name="workingDirectory">要启动的过程的目录</param> /// <param name="command">要履行的命令</param> public static void StartCmd(String workingDirectory, String command) {  ,ARP用PC TOOLFirewall 如何防得住; Process p = new Process(); p.StartInfo.FileName = "cmd.exe"; p.StartInfo.WorkingDirectory = workingDirectory; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardInput = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardError = true; p.StartInfo.CreateNoWindow = true; p.Start(); p.StandardInput.WriteLine(command); p.StandardInput.WriteLine("exit"); }
(责任编辑:admin)
|