您目前尚未登陆,请选择【登陆】或【注册
首页->留言本类->太糊留言板(VS2008+SQL2005)>>App-Code/DB.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:太糊留言板(VS2008+SQL2005)
当前文件:文件类型 TaiHuMessage/App_Code/DB.cs打开代码结构图
普通视图
		            
1using System; 2using System.Data; 3using System.Configuration; 4using System.Linq; 5using System.Web; 6using System.Web.Security; 7using System.Web.UI; 8using System.Web.UI.HtmlControls; 9using System.Web.UI.WebControls; 10using System.Web.UI.WebControls.WebParts; 11using System.Xml.Linq; 12using System.Data.SqlClient; 13 14/// <summary> 15///DB 的摘要说明 16/// </summary> 17public class DB 18{ 19 public int pagetotal; 20 SqlConnection con = new SqlConnection(); 21 SqlCommand cmd = new SqlCommand(); 22 public DB() 23 { 24 // 25 //TODO: 在此处添加构造函数逻辑 26 // 27 28 29 } 30 public SqlConnection GetConnection() 31 { 32 con = new SqlConnection("server=.\\SQL2005;database=message;User Id=sa;Password=sa"); 33 if (con.State == ConnectionState.Closed) 34 con.Open(); 35 return con; 36 } 37 public void CloseConnection() 38 { 39 40 if (con.State == ConnectionState.Open) 41 con.Close(); 42 } 43 public int Command(string SqlStr) 44 { 45 GetConnection(); 46 cmd = new SqlCommand(SqlStr,con); 47 48 int result = cmd.ExecuteNonQuery(); 49 return result; 50 51 } 52 public int Scalar(string SqlStr) 53 { 54 int num; 55 GetConnection (); 56 cmd = new SqlCommand(SqlStr, con); 57 num=Convert.ToInt32( cmd.ExecuteScalar()); 58 return num; 59 } 60 61 62 63} 64
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:太糊留言板(VS2008+SQL2005)
51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号