【文章內(nèi)容簡(jiǎn)介】
ar(60) not null,內(nèi)容 ntext not null,時(shí)間 datetime,首頁(yè)顯示 char(250) not null) str = str amp。 create table 日志留言 (id int identity primary key,賬號(hào) char(20) not null,留言 char(800) not null,時(shí)間 datetime,系號(hào) int not null,標(biāo)題 nchar(60) not null,所屬 char(40)) str = str amp。 create table 留言 (系號(hào) int identity primary key,賬號(hào) char(20) not null,內(nèi)容 char(800) not null,時(shí)間 datetime) str = str amp。 create table 賬戶 (賬號(hào) char(20) primary key,密碼 char(20) not null,郵箱 char(25),用戶組 char(10) not null)str = str amp。 insert 賬戶(賬號(hào),密碼,用戶組) values(@zh,@mm,@group) ’建表SQL代碼 Try = Data Source= amp。 ip amp。 。User ID= amp。 zh amp。 。Password= amp。 mm amp。 ’連接數(shù)據(jù)庫(kù) () = use amp。 sql amp。 amp。 str amp。 ’建表代碼集 (@zh, ).Value = root (@mm, ).Value = login (@group, ).Value = group = myconn () Catch ex As Exception () () (scriptalert(39。發(fā)生錯(cuò)誤,連接失敗!39。)。=39。?ip= amp。 ip amp。 amp。zh= amp。 zh amp。 amp。mm= amp。 mm amp。 amp。sql= amp。 sql amp。 39。/script) End Try () () = False = False = False = False = False = False = False = False = 完成安裝,進(jìn)入根文件夾下把 和 這兩個(gè)網(wǎng)頁(yè)文件刪除 ’完成安裝時(shí)建表頁(yè)面顯示的提示信息 End Sub博客前臺(tái)頁(yè)面實(shí)現(xiàn)目標(biāo):顯示最新日志簡(jiǎn)要內(nèi)容,可以根據(jù)選擇進(jìn)入日志、留言、登入、注冊(cè)頁(yè)面,有比較綜合的鏈接顯示。-3所示:在首頁(yè)TreeView1顯示日志欄目GridView1顯示最新日志信息,可以直接選擇要看的日志欄目鏈接到日志頁(yè)面并且顯示鏈接欄目下的子日志,還可以根據(jù)直接查看最新日志。登入后的用戶根據(jù)身份驗(yàn)證LinkButton1顯示后臺(tái)管理鏈接或個(gè)人信息管理鏈接,信息顯示頁(yè)面由此頁(yè)面的個(gè)人信息管理鏈接引導(dǎo),只供一般用戶使用,在信息顯示頁(yè)面()可以進(jìn)入信息修改頁(yè)面(),如果用戶登入后要繼續(xù)登入,首頁(yè)在用戶登入后有登出操作。:顯示控件GridView1所要添加TemplateField的列為“查看”,頁(yè)面所要添加的代碼為: itemtemplatea style=color: teal。 href=?id=%eval(id)% target= span style=color: teal。閱讀/span /a/itemtemplate圖1-3Page_load和createchildtree過程的VB代碼:Imports Imports Imports Dim uid As StringDim group As IntegerProtected Sub Page_Load(ByVal sender As Object, ByVal e As ) Handles uid = Session(uid) ’獲取登入用戶的用戶名 If Not Then If uid Then = uid Dim myconn As New SqlConnection Dim mym As New SqlCommand Dim myreader As SqlDataReader = (conn).ConnectionString () = select count(*) from 賬戶 where 賬號(hào)=@uid and 用戶組=39。管理員39。 (@uid, ).Value = uid = = myconn myreader = () group = (0) ’判斷登入者是否為管理員 () If group 0 Then = 后臺(tái)管理 = ~/ ’管理員登入時(shí)鏈接 Else = 個(gè)人信息管理 = ~/ ’一般用戶登入時(shí)鏈接 End If Else = False = False = False = 歡迎你來到眷海存楓博客 ’匿名訪問時(shí)顯示 = ~/ ’匿名訪問時(shí)顯示文字的鏈接 End If Dim tn As New TreeNode = 首頁(yè) = () createchildtree(tn, 0) ’調(diào)用過程 (tn) End If End Sub Protected Sub createchildtree(ByVal parentnode, ByVal parentid) ’樹目錄的過程 Dim myconn As New SqlConnection Dim mym As New SqlCommand Dim myreader As SqlDataReader Dim tn As TreeNode = (conn).ConnectionString () = select * from 日志欄 where rootid=@rootid (@rootid, ).Value = parentid = = myconn myreader = () Do While () ’從表的第一行開始讀取 tn = New TreeNode = myreader(txt).ToString = ? amp。id= amp。 myreader(id) createchildtree(tn, myreader(id)) ’樹的遞歸調(diào)用 (tn) ’添加子樹 Loop () () ()End Sub登出按鈕LinkButton2_Click事件代碼如下:Protected Sub LinkButton2_Click(ByVal sender As Object, ByVal e As ) Handles Session(uid) = ’登出,把傳遞的用戶名置為空 () ’返回博客首頁(yè) End Sub實(shí)現(xiàn)目標(biāo):查看日志和搜索日志,搜索日志可以根據(jù)日志標(biāo)題,也可以根據(jù)日志內(nèi)容。左邊目錄樹查看日志欄目下所有的日志。-4所示:在日志頁(yè)面默認(rèn)打開時(shí)GridView1顯示所有的日志,左邊欄目TreeView1可以選擇所要對(duì)應(yīng)欄目下日志,日志顯示欄可以直接點(diǎn)擊查看鏈接查看日志詳細(xì)內(nèi)容,Button1_Click事件提供日志搜索,根據(jù)標(biāo)題搜索,也可以根據(jù)內(nèi)容搜索,搜索顯示日志標(biāo)題而不顯示日志內(nèi)容,日志詳細(xì)內(nèi)容是在日志顯示頁(yè)面()顯示。:顯示控件GridView1所要添加TemplateField的列為“日志查看”,頁(yè)面所要添加的代碼為:itemtemplatea style=color: teal。 href=?id=%eval(id)% target= span style=color: teal。查看/span /a/itemtemplate日志搜索按鈕Button1_Click事件VB代碼:Protected Sub Button1_Click(ByVal sender As Object, ByVal e As ) Handles Dim str As String str = ’取出選擇搜索的條件 If str = 日志標(biāo)題 Then ’選擇搜索的條件為日志標(biāo)題 = (conn).ConnectionString = select id,標(biāo)題,時(shí)間 from 日志庫(kù) where 標(biāo)題 like39。% amp。 amp。 %39。 order by 時(shí)間 desc Else If str = 日志內(nèi)容 Then ’選擇搜索的條件為日志內(nèi)容 = (conn).ConnectionString = select id,標(biāo)題,時(shí)間 from 日志庫(kù) where 內(nèi)容 like39。% amp。 amp。 %39。 order by 時(shí)間 desc End If End If End Sub圖1-4Page_load和createchildtree過程的VB代碼:Imports Imports Imports Dim dateid As StringProtected Sub Page_Load(ByVal sender As Object, ByVal e As ) Handles If Not Then dateid = (id) Dim myconn As New SqlConnection Dim mym As New SqlCommand Dim tn As New TreeNode = 首頁(yè) = () createchildtree(tn, 0) (tn) If dateid Then = (conn).ConnectionString = select id,標(biāo)題,時(shí)間 from 日志庫(kù) where 欄目id=39。 amp。 CInt(dateid) amp。 39。 order by 時(shí)間 desc Else = (conn).ConnectionString = select id,標(biāo)題,時(shí)間 from 日志庫(kù) order by 時(shí)間 desc End If End If End SubProtected Sub createchildtree(ByVal parentnode, ByVal parentid) ’樹目錄的過程 Dim myconn As New SqlConne