温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:晶晶Vb.net留言板源码
当前文件:
VbGuestBook/reply.aspx.vb,打开代码结构图
VbGuestBook/reply.aspx.vb,打开代码结构图1Imports System 2
Imports System.ComponentModel 3
Imports System.Data 4
Imports System.Data.OleDb 5
Imports System.Web 6
Imports System.Web.SessionState 7
Imports System.Web.UI 8
Imports System.Web.UI.WebControls 9
Imports System.Configuration 10
Imports Microsoft.VisualBasic 11
12
Public Class reply 13
Inherits System.Web.UI.Page 14
Protected WithEvents LB As System.Web.UI.WebControls.Label 15
Protected WithEvents Button1 As System.Web.UI.WebControls.Button 16
Protected WithEvents Button2 As System.Web.UI.WebControls.Button 17
Protected WithEvents TB As System.Web.UI.WebControls.TextBox 18
19
Web 窗体设计器生成的代码 33
34
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 35
If Session("name") <> ConfigurationSettings.AppSettings("站长") Then Response.Redirect("default.aspx") 36
Dim ID As String, page As String 37
ID = Request.QueryString("ID") 38
page = Request.QueryString("page") 39
If ID.Length < 1 Then Response.Redirect("default.aspx") 40
If Not IsPostBack Then 41
Dim conn As OleDbConnection, comd As OleDbCommand, dr As OleDbDataReader 42
conn = New OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data Source=" & Server.MapPath(ConfigurationSettings.AppSettings("数据库"))) 43
comd = New OleDbCommand("Select 内容,回复 From 留言 Where ID=" + ID, conn) 44
comd.Connection.Open() 45
dr = comd.ExecuteReader 46
If dr.Read Then 47
LB.Text = dr(0) 48
TB.Text = dr(1).ToString 49
Else 50
Response.Redirect("default.aspx") 51
End If 52
dr.Close() 53
comd.Connection.Close() 54
comd.Dispose() 55
conn.Close() 56
conn.Dispose() 57
End If 58
End Sub 59
60
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click 61
Response.Redirect("default.aspx") 62
End Sub 63
64
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 65
Dim ID As String, page As String, text As String 66
ID = Request.QueryString("ID") 67
page = Request.QueryString("page") 68
If ID.Length < 1 Then Response.Redirect("default.aspx") 69
Dim conn As OleDbConnection, comd As OleDbCommand 70
conn = New OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data Source=" & Server.MapPath(ConfigurationSettings.AppSettings("数据库"))) 71
comd = New OleDbCommand("Update 留言 Set 回复=@p1 Where ID=" + ID, conn) 72
comd.Parameters.Add(New OleDbParameter("@p1", OleDbType.Char)) 73
text = TB.Text 74
If text.Length < 1 Then text = "谢谢你的留言" 75
text = Replace(text, vbCrLf, "<br>") 76
comd.Parameters("@p1").Value = text 77
comd.Connection.Open() 78
comd.ExecuteNonQuery() 79
comd.Connection.Close() 80
comd.Dispose() 81
conn.Close() 82
conn.Dispose() 83
Response.Redirect("default.aspx?page=" + page) 84
End Sub 85
End Class 86







