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

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 masterall 的 blog

].value = n_topic.content ;

try


myconn.open() ;
mycommand.executenonquery() ;

//清场

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 ;
}

}
}


本文关键:利用c#制作简单的留言板(1)
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top