Asp.net源码专业站
首页->影音娱乐->香蕉视频网源码>>com.bn388.DBHelper/sqltext.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:香蕉视频网源码
当前文件:文件类型 BnVideo/com.bn388.DBHelper/sqltext.cs[6K,2009-6-12 11:34:38]打开代码结构图
普通视图
		            
1using System; 2using System.Collections; 3using System.Collections.Generic; 4using System.Text; 5 6//该源码下载自www.51aspx.com(51aspx.com) 7 8namespace com.bn388.DBHelper 9{ 10 public class sqltext 11 { 12 public static string insert(Hashtable ht, string table) 13 { 14 string keys = ""; 15 string values = ""; 16 int i = 0; 17 string value; 18 foreach (DictionaryEntry de in ht) 19 { 20 if (isInt(de.Value.ToString())) 21 { 22 value = de.Value.ToString(); 23 } 24 else 25 { 26 value = "'" + de.Value.ToString() + "'"; 27 } 28 29 if (i == 0) 30 { 31 keys = de.Key.ToString(); 32 values = value; 33 } 34 else 35 { 36 keys += "," + de.Key.ToString(); 37 values += "," + value; 38 } 39 i += 1; 40 } 41 42 return "insert into " + table + " (" + keys + ") values(" + values + ")"; 43 } 44 45 public static string delete(string table, string _where) 46 { 47 return "delete from " + table + " where " + _where; 48 } 49 50 public static string update(Hashtable ht, string table, string _where) 51 { 52 string keys = ""; 53 string value; 54 int i = 0; 55 56 foreach (DictionaryEntry de in ht) 57 { 58 if (isInt(de.Value.ToString())) 59 { 60 value = de.Value.ToString(); 61 } 62 else 63 { 64 value = "'" + de.Value.ToString() + "'"; 65 } 66 67 if (i == 0) 68 { 69 keys = de.Key.ToString() + "=" + value; 70 } 71 else 72 { 73 keys += "," + de.Key.ToString() + "=" + value; 74 } 75 i += 1; 76 } 77 return "update " + table + " set " + keys + " where " + _where; 78 } 79 80 public static string update_(string key, int value, string table, string _where) 81 { 82 return "update " + table + " set " + key + "=" + key + "+" + value + " where " + _where; 83 } 84 85 public static string select(string top, string key, string table, string _where, string order) 86 { 87 string key_ = ""; 88 StringBuilder sb = new StringBuilder("select"); 89 90 if (!String.IsNullOrEmpty(top)) 91 { 92 sb.Append(" top " + top); 93 } 94 95 if (String.IsNullOrEmpty(key)) 96 { 97 key_ = "*"; 98 } 99 else 100 { 101 key_ = key; 102 } 103 104 sb.Append(" " + key_ + " from " + table); 105 106 if (!String.IsNullOrEmpty(_where)) 107 { 108 sb.Append(" where " + _where); 109 } 110 111 if (!String.IsNullOrEmpty(order)) 112 { 113 sb.Append(" order by " + order); 114 } 115 116 return sb.ToString(); 117 } 118 119 public static string select_mysql(string top, string key, string table, string _where, string order) 120 { 121 string key_ = ""; 122 123 if (String.IsNullOrEmpty(key)) 124 { 125 key_ = "*"; 126 } 127 else 128 { 129 key_ = key; 130 } 131 132 StringBuilder sb = new StringBuilder("select " + key_ + " from " + table); 133 134 if (!String.IsNullOrEmpty(_where)) 135 { 136 sb.Append(" where " + _where); 137 } 138 139 if (!String.IsNullOrEmpty(order)) 140 { 141 sb.Append(" order by " + order); 142 } 143 144 if (!String.IsNullOrEmpty(top)) 145 { 146 sb.Append(" limit " + top); 147 } 148 149 return sb.ToString(); 150 } 151 152 public static string count(string key, string table, string _where) 153 { 154 StringBuilder sb = new StringBuilder("select count(" + key + ") from " + table); 155 if (!String.IsNullOrEmpty(_where)) 156 { 157 sb.Append(" where " + _where); 158 } 159 return sb.ToString(); 160 } 161 162 public static string avg(string key, string table, string _where) 163 { 164 StringBuilder sb = new StringBuilder("select avg(" + key + ") from " + table); 165 if (!String.IsNullOrEmpty(_where)) 166 { 167 sb.Append(" where " + _where); 168 } 169 return sb.ToString(); 170 } 171 172 public static string max(string key, string table, string _where) 173 { 174 StringBuilder sb = new StringBuilder("select max(" + key + ") from " + table); 175 if (!String.IsNullOrEmpty(_where)) 176 { 177 sb.Append(" where " + _where); 178 } 179 return sb.ToString(); 180 } 181 182 public static string min(string key, string table, string _where) 183 { 184 StringBuilder sb = new StringBuilder("select min(" + key + ") from " + table); 185 if (!String.IsNullOrEmpty(_where)) 186 { 187 sb.Append(" where " + _where); 188 } 189 return sb.ToString(); 190 } 191 192 public static string sum(string key, string table, string _where) 193 { 194 StringBuilder sb = new StringBuilder("select sum(" + key + ") from " + table); 195 if (!String.IsNullOrEmpty(_where)) 196 { 197 sb.Append(" where " + _where); 198 } 199 return sb.ToString(); 200 } 201 202 public static string instr(string columns, string table, string key, string value) 203 { 204 return "select " + columns + " from " + table + " where instr (" + key + ",'" + value + "')"; 205 } 206 207 protected static bool isInt(string str) 208 { 209 try 210 { 211 Convert.ToInt32(str); 212 return true; 213 } 214 catch 215 { 216 return false; 217 } 218 } 219 220 } 221} 222
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:香蕉视频网源码
51Aspx.com 版权所有 CopyRight © 2006-2010. 京ICP备06046876号 本站法律顾问:ITlaw-庄毅雄律师
返回顶部
客户服务:点击这里进行客户咨询 业务合作:点击这里洽谈业务合作 合作热线:010-68880146