您目前尚未登陆,请选择【登陆】或【注册
首页->功能源码->Web图片管理系统代码>>App-Code/SQLHelper.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:Web图片管理系统代码
当前文件:文件类型 PictureManager/App_Code/SQLHelper.cs打开代码结构图
普通视图
		            
1using System; 2using System.Data; 3using System.Configuration; 4using System.Web; 5using System.Web.Security; 6using System.Web.UI; 7using System.Web.UI.WebControls; 8using System.Web.UI.WebControls.WebParts; 9using System.Web.UI.HtmlControls; 10using System.Data.SqlClient; 11/// <summary> 12/// SQLHelper 的摘要说明 13/// </summary> 14//该源码下载自www.51aspx.com(51aspx.com) 15 16public class SQLHelper 17{ 18 private static string connStr = System.Configuration.ConfigurationManager.AppSettings["connStr"]; 19 private SqlConnection conn = null; 20 private SqlCommand cmd = null; 21 private SqlDataAdapter adapter = null; 22 private DataSet dataset = null; 23 public SQLHelper() 24 { 25 // 26 // TODO: 在此处添加构造函数逻辑 27 conn = new SqlConnection(connStr); 28 cmd = new SqlCommand(); 29 cmd.Connection = conn; 30 } 31 private void openConn() 32 { 33 if (conn.State ==ConnectionState.Closed) 34 { 35 conn.Open(); 36 } 37 } 38 private void closeConn() 39 { 40 if (conn.State == ConnectionState.Open) 41 { 42 conn.Close(); 43 } 44 } 45 // 验证节点是否为目录 46 public bool checkdir(string strID) 47 { 48 bool dt; 49 string tempCmd = "SELECT isDir FROM Images WHERE ImgID=" + strID; 50 try 51 { 52 this.openConn(); 53 cmd.CommandText = tempCmd; 54 dt = Boolean.Parse(cmd.ExecuteScalar().ToString()); 55 } 56 catch (Exception ex) 57 { 58 throw ex; 59 60 } 61 finally 62 { 63 this.closeConn(); 64 } 65 return dt; 66 } 67 68 public DataTable getpicinfo() 69 { 70 DataTable dt; 71 string tempCmd = "SELECT * FROM Images"; 72 try 73 { 74 this.openConn(); 75 cmd.CommandText = tempCmd; 76 adapter = new SqlDataAdapter(cmd); 77 dataset = new DataSet(); 78 adapter.Fill(dataset); 79 dt = dataset.Tables[0]; 80 } 81 catch (Exception ex) 82 { 83 throw ex; 84 } 85 finally 86 { 87 this.closeConn(); 88 } 89 return dt; 90 } 91 public bool checkchildnode(string strID) 92 { 93 bool dt; 94 string tempCmd = "SELECT COUNT(*) FROM Images WHERE ParentID="+strID; 95 try 96 { 97 this.openConn(); 98 cmd.CommandText = tempCmd; 99 dt = Int32.Parse(cmd.ExecuteScalar().ToString())>0?true:false; 100 } 101 catch(Exception ex) 102 { 103 throw ex; 104 } 105 finally 106 { 107 this.closeConn(); 108 } 109 return dt; 110 } 111 public void deleteNode(string strID) 112 { 113 string tempCmd = "DELETE Images WHERE ImgID="+strID; 114 try 115 { 116 this.openConn(); 117 cmd.CommandText = tempCmd; 118 cmd.ExecuteNonQuery(); 119 120 } 121 catch (Exception ex) 122 { 123 throw ex; 124 } 125 finally 126 { 127 this.closeConn(); 128 } 129 } 130 //添加节点 131 public void addNode(string name,string url,string isDir,string ParentID) 132 { 133 string tempCmd = "INSERT INTO Images (ImgName,ImgUrl,isDir,ParentID,CreateDate)VALUES" + "('" + name + "','" + url + "','" + isDir + "'," + ParentID + ",GetDate())"; 134 try 135 { 136 this.openConn(); 137 cmd.CommandText = tempCmd; 138 cmd.ExecuteNonQuery(); 139 140 } 141 catch (Exception ex) 142 { 143 throw ex; 144 145 } 146 finally 147 { 148 this.closeConn(); 149 } 150 } 151 //更新节点 152 public void updateNode(string strID, string name) 153 { 154 string tempCmd = "UPDATE Images SET ImgName='"+name+"'WHERE ImgID="+strID; 155 try 156 { 157 this.openConn(); 158 cmd.CommandText = tempCmd; 159 cmd.ExecuteNonQuery(); 160 161 } 162 catch (Exception ex) 163 { 164 throw ex; 165 } 166 finally 167 { 168 this.closeConn(); 169 } 170 } 171 172 173 174 175 }
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:Web图片管理系统代码
51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号