Sub Page_Load (sender as Object, E as EventArgs)
Datalist1.datasource = Createdataview ("Data.mdb", "Guestbook")
Datalist1.databind ()
End Sub
Function Createdataview (Db As String, Table as String) as DataView
Dim Provider, ConnStr, SQL as String
Provider = "microsoft.jet.oledb.4.0;"
ConnStr = "provider=" & Provider & _
"Data source=" & Server.MapPath (DB)
Dim CMD as Adodatasetcommand
CMD = New Adodatasetcommand ("Select * from" & Table & "ORDER by Post_time DESC", connstr)
Dim ds As DataSet = new DataSet ()
Cmd.filldataset (ds, Table)
Createdataview = new DataView (ds. Tables (Table))
End Function
Sub Datalist_itemcommand (sender as Object, E as DataListCommandEventArgs)
Select Case E.commandsource.text
Case "I want to speak"
Foot. Visible = True
Case "Management Message"
Case "View Details"
Datalist1.selectedindex = E.item.itemindex ' View message template is selected
Case "Off"
Datalist1.selectedindex =-1
End Select
Datalist1.datasource = Createdataview ("Data.mdb", "Guestbook")
Datalist1.databind ()
End Sub
Sub Linkbutton2_click (sender as Object, E as EventArgs)
Foot. Visible = False
End Sub
Sub LinkButton1_Click (sender as Object, E as EventArgs)
Dim connstr, SQL as String
SQL = "Insert into guestbook (username,post_time,content) Values ('" & Username.value & "', '" & DateTime.Now &A MP; "', '" & Content.value & "')"
ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data source=" & Server.MapPath ("Data.mdb")
Dim CMD as Adocommand = New Adocommand (SQL, CONNSTR)
Cmd.ActiveConnection.Open ()
Cmd.execute ()
message.innerhtml = "<B> message success!" </B> "
Foot. Visible = False
Page.navigate ("temp.aspx")
End Sub
</script>
Study for a long time, but the last sentence page.navigate ("temp.aspx") or to achieve the effect of timely refresh: (, see the Essence of a C # is compiled in the Page_ The Load event receives the Request.Form object after the insert is immediately updated dateset, do not know how to fix this ...
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.