;;
//清场
myConn.Close() ;
}
catch(Exception e)
{
throw(new Exception("取贴子失败:" + e.ToString())) ;
}
return true;
}
/// <summary>
/// 取的贴子列表
/// </summary>
/// <remarks>
/// 返回一个Topic数组
/// </remarks>
public ArrayList GetTopicList()
{
//定义一个forum数组做为返回值
ArrayList arrForumList =new ArrayList() ;
//从数据库中读取留言列表
myconn myConn = new myconn();
SQLCommand myCommand = new SQLCommand() ;
myCommand.ActiveConnection = myConn ;
myCommand.CommandText = "n_GetTopicList" ; //调用存储过程
myCommand.CommandType = CommandType.StoredProcedure ;
try
{
myConn.Open() ;
SQLDataReader myReader ;
myCommand.Execute(out myReader) ;
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) ;
}
//清场
myReader.Close();
myConn.Close() ;
}
catch(SQLException e)
{
throw(new Exception("数据库出错:" + e.ToString())) ;
//return null ;
}
return arrForumList ;
}
}
}
myconn.cs
namespace notpage
{
using System;
using System.Data.SQL ;</P><P> /// <summary>
/// Summary description for myconn.
/// </summary>
public class myconn:System.Data.SQL.SQLConnection
{
private void InitializeComponent ()
{
}
public myconn()
{
//
// TODO: Add Constructor Logic here
//
this.Database = "back" ;
this.DataSource = "LUOCHANG" ;
this.UserID = "sa" ;
this.Password = "" ;
}
}
}
添加留言addTopic.
aspx
<%@ Page languag