开发工具:
文件大小: 15kb
下载次数: 0
上传时间: 2010-03-07
详细说明: 用ASP.NET做的 using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.OleDb; /// /// Class1 的摘要说明 /// public class Class1 { private OleDbConnection m_Connection; private String m_brChar = "\n"; public Class1() { // // TODO: 在此处添加构造函数逻辑 // } private void ExecuteCommand(OleDbC ommand cmd) { cmd.Connection=m_Connection; try { m_Connection.Open(); cmd.ExecuteNonQuery(); } finally { m_Connection.Close(); } } public DataSet GetNotes(DateTime fromDate, DateTime toDate) { DataSet ds=new DataSet(); OleDbDataAdapter da=new OleDbDataAdapter("select * from Notes where DateTime BETWEEN ? and ? ORDER BY DateTime DESC",m_Connection); da.SelectCommand.Parameters.Add("FromDate", OleDbType.Date).Value = fromDate.AddDays(1); m_Connection.Open(); da.Fill(ds,"MyNotes"); m_Connection.Close(); return ds; } public void InsertNote(string title,string contents) { OleDbCommand cmd =new OleDbCommand ("insert into Notes(Title,Contents) values(?,?)"); cmd.Parameters .Add ("Title",OleDbType .VarChar ).Value =title ; cmd.Parameters .Add ("Contents",OleDbType .LongVarChar ).Value =contents.Replace (m_brChar ,"
"); ExecuteCommand (cmd); } public void InsertComment(int noteid,string author,string email,string comment) { OleDbCommand cmd=new OleDbCommand ("insert into Comments(NoteID,Author,Email,Comment) values(?,?,?,?)"); cmd.Parameters .Add ("NoteID",OleDbType .VarChar ).Value =noteid; cmd.Parameters .Add ("Author",OleDbType .VarChar ).Value =author ; cmd.Parameters .Add ("Email",OleDbType .VarChar ).Value =email ; cmd.Parameters .Add ("Comment",OleDbType .LongVarChar ).Value =comment.Replace (m_brChar ,"
"); ExecuteCommand (cmd); } public void UpdaeNote(int noteid, string title, string contents) { OleDbCommand cmd = new OleDbCommand("UPDATE [Notes] SET [Title]=?,[Contents]=? WHERE [NoteID]=?"); cmd.Parameters.Add("Title", OleDbType.VarChar).Value = title; cmd.Parameters.Add("Contents", OleDbType.LongVarChar).Value = contents.Replace(m_brChar, "
"); cmd.Parameters.Add("NoteID", OleDbType.Integer).Value = noteid; ExecuteCommand(cmd); } public void UpdateComment(int commentid,string author,string email,string comment) { OleDbCommand cmd =new OleDbCommand ("UPDATE Comments SET Author =?,Email=?,Comment=? WHERE CommentID=?"); cmd.Parameters .Add ("Author",OleDbType .VarChar ).Value =author; cmd.Parameters .Add ("Comment",OleDbType .LongVarChar).Value =comment.Replace (m_brChar ,"
"); cmd.Parameters.Add("Email", OleDbType.VarChar).Value = email; cmd.Parameters.Add("CommentID", OleDbType.VarChar).Value = commentid; ExecuteCommand(cmd); } public void DeleteNote(int noteid) { OleDbCommand cmd =new OleDbCommand ("delete from Notes where NoteID="+noteid); ExecuteCommand(cmd); } public void DeleteComment(int commentid) { OleDbCommand cmd =new OleDbCommand ("delete from Comments where CommentID="+commentid); ExecuteCommand (cmd); } public void GetNoteData(int noteid,ref string title,ref string contents,ref string post_time) { OleDbCommand cmd=new OleDbCommand ("select * from Notes where NoteID="+ noteid ,m_Connection ); try { m_Connection .Open(); OleDbDataReader reader=cmd.ExecuteReader (CommandBehavior .CloseConnection ); if(reader .Read ()) { title =reader ["Title"].ToString (); contents =reader ["Contents"].ToString ().Replace ("
",m_brChar ); post_time =reader ["DataTime"].ToString (); reader .Close (); } } finally { m_Connection .Close (); } } public void GetCommentData(int commentid,ref string author,ref string email,ref string comment) { OleDbCommand cmd=new OleDbCommand ("select * from Comments where CommentID="+commentid ,m_Connection ); try { m_Connection .Open (); OleDbDataReader reader=cmd.ExecuteReader (CommandBehavior .CloseConnection ); if(reader.Read ()) { author =reader ["Author"].ToString (); email =reader ["Comment"].ToString ().Replace ("
",m_brChar ); reader .Close (); } } finally { m_Connection .Close (); } } } /// /// data 的摘要说明 /// ...展开收缩
(系统自动生成,下载前可以参看下载内容)
下载文件列表
相关说明
- 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
- 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度。
- 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
- 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
- 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
- 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.