(读者可打开【光盘】|【源文件】|【实例 92 】|【 92.7.txt 】文件,直接复制) ( 15 )定义“ blogcancel_Click ”过程,用于响应【取消】链接按钮的“ OnClick ”事件。 Sub blogcancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) panel1.Visible = True panel2.Visible = False End Sub (读者可打开【光盘】|【源文件】|【实例 92 】|【 92.8.txt 】文件,直接复制) ( 16 )定义“ refer_Click ”过程,用于响应 【 发表 】 按钮的“ OnClick ”事件。 Sub refer_Click(ByVal sender As Object, ByVal e As System.EventArgs) Dim cpConn, Cpstring As String Dim conn As OleDbConnection Dim Cpadapter As OleDbDataAdapter Dim Cpdat As System.Data.DataSet Dim dt As DataTable cpConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath ("dat\bad.mdb") conn = New OleDbConnection(cpConn) If MyblogData.RecordCount > 0 Then Cpstring = "select * from myblog where myblogID=" & MyblogData.FieldValue ("myblogID", Nothing) Cpadapter = New OleDbDataAdapter(Cpstring, conn) Dim yy as OleDbCommandBuilder=new OleDbCommandBuilder (Cpadapter) Cpdat = New System.Data.DataSet() Cpadapter.Fill(Cpdat, "myblog") dt = Cpdat.Tables("myblog") dt.Rows(0)("myblog") = MyblogData.FieldValue("myblog", Nothing) + newmyblog. Text Else Cpstring = "select * from myblog" Cpadapter = New OleDbDataAdapter(Cpstring, conn) Dim yy as OleDbCommandBuilder=new OleDbCommandBuilder (Cpadapter) Cpdat = New System.Data.DataSet() Cpadapter.Fill(Cpdat, "myblog") Dim dr As DataRow dr = Cpdat.Tables("myblog").NewRow dr("title") = newtitle.Text dr("myblog") = newmyblog.Text dr("myblogtm")=today Cpdat.Tables("myblog").Rows.Add(dr) End If Cpadapter.Update(Cpdat, "myblog") panel1.Visible = True Response.Redirect(Request.ServerVariables("SCRIPT_NAME")) End Sub (读者可打开【光盘】|【源文件】|【实例 92 】|【 92.9.txt 】文件,直接复制) 程序说明: 由于网络日记每天只限一篇,为了防止用户在发表完随笔后再发表随笔,程序设置如果已发表了随笔,那么再发表随笔时,只是把发表的内容加在原来随笔的后面进行更新。 实例 91 到实例 93 介绍了简单 BLOG 的实现,留言本、论坛的实现与 BLOG 十分类似,由于篇幅的关系,这里就不对它们进行介绍了。至此,本实例操作完毕。 |