1. Use Access to build a database data. MDB and create a table guest. The structure is as follows:
Id automatic number
Title string
Signature string
Body remarks.
2. Guest. aspx
<% @ Import namespace = "system. Data" %>
<% @ Import namespace = "system. Data. oledb" %>
<HTML>
<Style>
<! --
Body {font-size: 9pt}
P {font-size: 9pt}
TD {font-size: 9pt}
// -->
</Style>
<Title> message book </title>
<Body>
<P align = right> <font size = 6> message book </font> </P>
<Script language = VB runat = Server>
Sub page_load (source as object, e as eventargs)
Dim myconn as new oledbconnection ("provider = Microsoft. Jet. oledb.4.0; Data Source =" & server. mappath ("data. mdb "))
Dim myadapter as new oledbdataadapter
Dim myoledbcommandbuilder as oledbcommandbuilder = new oledbcommandbuilder (myadapter)
Dim ds as dataset = new dataset
Myadapter. selectcommand = new oledbcommand ("select ID, title, signature from guest order by id desc", myconn)
Myconn. open ()
Myadapter. Fill (DS, "guest ")
ML. datasource = Ds. Tables ("guest"). defaultview
ML. databind ()
End sub
</SCRIPT>
<Asp: DataGrid id = "ML" runat = "server"
Width = "100%"
Bordercolor = "black"
Showfooter = "false"
Cellpadding = 3
Cellspacing = "0"
Font-name = ""
Font-size = "9pt"
Headerstyle-backcolor = "# ddaacc"
Enableviewstate = "false"
>
<Columns>
<Asp: hyperlinkcolumn
Datanavigateurlfield = "ID"
Datanavigateurlformatstring = "see. asp? Id = {0 }"
TEXT = "see! "
Target = "_ new"
/>
</Columns>
</ASP: DataGrid>
<Br> <font size = 5> Leave a message </font> <br>
<Form method = post action = Send. aspx>
Title: <input type = text name = title> <br>
Signature: <input type = text name = Name> <br>
Content: <textarea name = body> </textarea> <br>
<Input type = submit>
</Form> |
3. Send. aspx
<% @ import namespace = "system. data "%>
<% @ import namespace =" system. data. oledb "%>
|
4. See. asp (it is better to use ASP to display a single data)
|
<HTML>
<Style>
<! --
Body {font-size: 9pt}
P {font-size: 9pt}
TD {font-size: 9pt}
// -->
</Style>
<Title> View comments </title>
<Body>
<P align = right> <font size = 6> View message </font> </P>
<%
Id = request ("ID ")
Set Cn = server. Createobject ("ADODB. Connection ")
CN. Open "DBQ =" + server. mappath ("data. mdb") + "; defaultdir =; driver = {Microsoft Access Driver (*. mdb )};"
Set rs = server. Createobject ("ADODB. recordset ")
Rs. Open "select * From guest where id =" & ID, CN
%>
ID: <% = ID %> <br>
Title: <% = RS ("title") %> <br>
Signature: <% = RS ("signature") %> <br>
Content: <br> <% = RS ("content") %> <br>
<A href = "guest. aspx"> return </a> |