Asp.net源码专业站
首页->新闻文章->风讯dotNETCMSv1.0免安装版源码>>Foosun.CMS/Database.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:风讯dotNETCMSv1.0免安装版源码
当前文件:文件类型 FooSunCMS/Foosun.CMS/Database.cs[4K,2009-6-12 11:42:42]打开代码结构图
普通视图
		            
1//=========================================================== 2//== (c)2007 Foosun Inc. by dotNETCMS 1.0 == 3//== Forum:bbs.foosun.net == 4//== website:www.foosun.net == 5//== Address:NO.109 HuiMin ST.,Chengdu ,China == 6//== TEL:86-28-85098980/66026180 == 7//== qq:655071,MSN:ikoolls@gmail.com == 8//== Code By Xi.deng == 9//=========================================================== 10using System; 11using System.Collections.Generic; 12using System.Text; 13using Foosun.DALFactory; 14using Foosun.CMS; 15using Foosun.Model; 16using System.IO; 17using System.Data; 18 19namespace Foosun.CMS 20{ 21 public class Database 22 { 23 private IDatabase data; 24 public Database() 25 { 26 data = DataAccess.CreateDatabase(); 27 } 28 29 public DataTable ExecuteSql(string sqlText) 30 { 31 DataTable dt = data.ExecuteSql(sqlText); 32 return dt; 33 34 } 35 36 public int backSqlData(int type, string backpath) 37 { 38 return data.backSqlData(type, backpath); 39 } 40 41 public int DbBak(string sourcePath, string desPath) 42 { 43 int result = 0; 44 if (File.Exists(sourcePath)) 45 { 46 try 47 { 48 FileInfo Fso = new FileInfo(sourcePath); //实例化FSO对象 49 Fso.CopyTo(desPath); //备份数据库到指定目录 50 result = 1; 51 52 } 53 catch 54 { 55 result = 2; 56 } 57 } 58 else 59 { 60 result = 3; 61 } 62 return result; 63 } 64 65 public int DbRar(string rarSourcePath, string rarTempPath, string rarStr_S, string rarStr_T) 66 { 67 int result = 0; 68 if (File.Exists(rarSourcePath)) //判断数据库文件是否存在 69 { 70 JRO.JetEngine Jet = new JRO.JetEngineClass(); //实例化JET引掣 71 if (File.Exists(rarTempPath)) 72 { 73 try 74 { 75 File.Delete(rarTempPath); 76 } 77 catch 78 { 79 result = 1; //删除存在的数据库文件失败 80 } 81 } 82 Jet.CompactDatabase(rarStr_S, rarStr_T); //压缩数据库 83 try 84 { 85 File.Delete(rarSourcePath); //删除源数据库 86 File.Move(rarTempPath, rarSourcePath); //移动新文件到指定地方并且指定文件名 87 File.Delete(rarTempPath); //删除临时数据库文件 88 result = 3; //压缩数据库成功! 89 } 90 catch (Exception e) 91 { 92 result = 2; 93 throw e; 94 //操作失败 95 } 96 } 97 else 98 { 99 result = 4; //数据库不存在! 100 } 101 return result; 102 } 103 104 public int DelBakDb(string bakPath) 105 { 106 int result = 0; 107 FileInfo Fso = new FileInfo(bakPath); //实例化FSO对象 108 try 109 { 110 Fso.Delete(); //删除此文件 111 } 112 catch //容错处理,提取IO异常 113 { 114 result = 2; //失败 115 } 116 result = 1; //成功 117 return result; 118 } 119 120 public void Replace(string oldTxt, string newTxt, string Table, string FieldName) 121 { 122 data.Replace(oldTxt, newTxt, Table, FieldName); 123 } 124 } 125 126} 127
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:风讯dotNETCMSv1.0免安装版源码
51Aspx.com 版权所有 CopyRight © 2006-2010. 京ICP备06046876号 本站法律顾问:ITlaw-庄毅雄律师
返回顶部
客户服务:点击这里进行客户咨询 业务合作:点击这里洽谈业务合作 合作热线:010-68880146