网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > C#应用
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket
网络编程:ASP教程,ASP.NET教程,PHP教程,JSP教程,C#教程,数据库,XML教程,Ajax,Java,Perl,Shell,VB教程,Delphi,C/C++教程,软件工程,J2EE/J2ME,移动开发
本月文章推荐
.信息反馈-邮件(数据库是XML) .
.用C#开发智能手机软件:推箱子(二.
.用Visual C#来清空回收站(1).
.C#注册表的读,写,删除,查找.
.C#制作MID窗体.
.通过win32api让c#控制Windows任务.
.从小处看C#.net垃圾回收.
.捕捉摄相头的数据流 .
.C#利用正则表达式实现字符串搜索.
.C#实现根据域名查询ip实例.
.发送邮件程序(Csharp2005).
.远程注册表读取,与多线程池的应用.
.用C#实现智能设备上的NotifyIcon.
.在C#中利用SharpZipLib进行文件的.
.浅析.NET开发中代理模式的使用.
.C#得到系统进程和结束某个指定的.
.一个产生中文累计数的代码片断.
.用C#开发网络防火墙技术分析.
.怎样在你的应用程序中集成Google.
.C#-委托和事件.

利用c#制作简单的留言板(1)

发表日期:2003-12-29


首先要感谢bigeagle的帮助,这个也是参考她的bbs做成的
留言板分三个模块:列出留言列表、显示详细内容、发表留言
notepage.cs
namespace notpage
{
using System;
using System.Data.SQL ;
using System.Data ;
using System.Collections ;
</P><P>
////////////////////////////////////////////////////////////////////
//
// Class Name : 留言板
//
// Description: 构造一个留言板对象
//
// date: 2000/06/06
//
// 作者: 天啦
/// ////////////////////////////////////////////////////////////////</P><P>
/// <summary>
/// Summary description for notepage.
/// </summary>


public class notepage
{
//私有变量

private int n_intID ; //ID编号
private string n_strTitle ; //主题
private string n_strAuthor ; //留言人
private string n_strContent ; //留言内容
private DateTime n_dateTime ; //留言时间</P><P>
//属性
</P><P> public int ID
{
get
{
return n_intID ;
}
set
{
n_intID = value;
}
}</P><P> public string Title
{
get
{
return n_strTitle ;
}
set
{
n_strTitle = value;
}
}</P><P> public string Author
{
get
{
return n_strAuthor ;
}
set
{
n_strAuthor = value ;
}
}
public string Content
{
get
{
return n_strContent ;
}
set
{
n_strContent = value ;
}
}
public DateTime adddate
{

get
{
return n_dateTime;
}
set
{
n_dateTime = value;
}
}
//构造函数
public notepage()
{
//
// TODO: Add Constructor Logic here
//
this.n_intID = 0 ;
this.n_strTitle = "" ;
this.n_strAuthor = "" ;
this.n_strContent = "" ;
this.n_dateTime = System.DateTime.Now;

}</P><P> /// <summary>
///
/// 取得留言的内容
///
/// </summary>
/// <param name="a_intID"> </param>
public notepage GetTopic(int a_intID)
{
//
// TODO: Add Constructor Logic here
//
</P><P>
//读取数据库
myconn myConn = new myconn();

SQLCommand myCommand = new SQLCommand() ;
myCommand.ActiveConnection = myConn ;
myCommand.CommandText = "n_GetTopicInfo" ; //调用存储过程
myCommand.CommandType = CommandType.StoredProcedure ;
myCommand.Parameters.Add(new SQLParameter("@a_intTopicID" , SQLDataType.Int)) ;
myCommand.Parameters["@a_intTopicID"].Value = a_intID ;</P><P> notepage objNp = new notepage();
try
{

myConn.Open() ;
SQLDataReader myReader ;
myCommand.Execute(out myReader) ;
if (myReader.Read())
{
objNp.ID = (int)myReader["ID"] ;
objNp.Title = (string)myReader["Title"] ;
objNp.Author = (string)myReader["Author"] ;
objNp.Content = (string)myReader["Content"];
objNp.adddate = (DateTime)myReader["adddate"];
}
</P><P>
//清场
myReader.Close();
myConn.Close() ;</P><P> }
catch(Exception e)
{
throw(new Exception("取贴子失败:" + e.ToString())) ;
}
return objNp;

}</P><P> /// <summary>
///
/// 目的:将留言的内容入库
///
/// 利用构造函数来传递信息
///
/// </summary>
/// <param name="n_Topic"> </param>
public bool AddTopic(notepage n_Topic)
{
//
// TODO: Add Constructor Logic here
//

//读取数据库
myconn myConn = new myconn();

SQLCommand myCommand = new SQLCommand() ;
myCommand.ActiveConnection = myConn ;
myCommand.CommandText = "n_addTopic" ; //调用存储过程
myCommand.CommandType = CommandType.StoredProcedure ;
myCommand.Parameters.Add(new SQLParameter("@a_strTitle" , SQLDataType.VarChar,100)) ;
myCommand.Parameters["@a_strTitle"].Value = n_Topic.Title ;</P><P> myCommand.Parameters.Add(new SQLParameter("@a_strAuthor" , SQLDataType.VarChar,50)) ;
myCommand.Parameters["@a_strAuthor"].Value = n_Topic.Author ;</P><P> myCommand.Parameters.Add(new SQLParameter("@a_strContent" , SQLDataType.VarChar,2000)) ;
myCommand.Parameters["@a_strContent"].Value = n_Topic.Content ;</P><P> try
{

myConn.Open() ;
myCommand.ExecuteNonQuery() ;

//清场

myConn.Close() ;</P><P> }
catch(Exception e)
{
throw(new Exception("取贴子失败:" + e.ToString())) ;
}
return true;

</P><P> }</P><P>
/// <summary>
/// 取的贴子列表
/// </summary>
/// <remarks>
/// 返回一个Topic数组
/// </remarks>
public ArrayList GetTopicList()
{
//定义一个forum数组做为返回值
ArrayList arrForumList =new ArrayList() ;</P><P> //从数据库中读取留言列表
myconn myConn = new myconn();
SQLCommand myCommand = new SQLCommand() ;
myCommand.ActiveConnection = myConn ;
myCommand.CommandText = "n_GetTopicList" ; //调用存储过程
myCommand.CommandType = CommandType.StoredProcedure ;</P><P> try
{
myConn.Open() ;
SQLDataReader myReader ;
myCommand.Execute(out myReader) ;</P><P> for (int i = 0 ; myReader.Read() ; i++)
{
notepage objItem = new notepage() ;
objItem.ID = myReader["ID"].ToString().ToInt32() ;
objItem.Title = myReader["Title"].ToString() ;
objItem.Author = myReader["Author"].ToString() ;
objItem.adddate = myReader["adddate"].ToString().ToDateTime();
objItem.Content = myReader["Content"].ToString();

arrForumList.Add(objItem) ;
}</P><P>
//清场
myReader.Close();
myConn.Close() ;</P><P> }
catch(SQLException e)
{
throw(new Exception("数据库出错:" + e.ToString())) ;
//return null ;
}</P><P> return arrForumList ;
}

}
}

上一篇:C#消息队列应用程序 -2 人气:12232
下一篇:利用c#制作简单的留言板(2) 人气:12905
浏览全部利用c#制作简单的留言板的内容 Dreamweaver插件下载 网页广告代码 祝你圣诞节快乐 2009年新年快乐