계층형게시판만들기강좌는 이미 선행한 게시판만들기를 학습한 사람을 대상으로 하겠습니다. 먼저 간단한 access 파일을 다음과 같이 작성합니다.





<form method=POST action=insert.asp>
<table border=1 width=400>
<tr>
<td align=center>제목</td>
<td><input type=text name=title size=50></td>
</tr>
<tr>
<td align=center>이름</td>
<td><input type=text name=name size=50></td>
</tr>
<tr>
<td align=center>글</td>
<td><textarea rows=10 name=comment cols=50></textarea></td>
</tr>
<tr>
<td align=right colspan=2>
<input type=submit value=글저장>
</td></tr>
</table>
</form>




<!--METADATA TYPE= "typelib"  NAME= "ADODB Type Library"
      FILE="C:\Program Files\Common Files\SYSTEM\ADO\msado15.dll"  -->
<%


Dim name, title, comment
name = Request.form("name")
title = Request.form("title")
comment = Request.form("comment")

Dim strConnect
strConnect="Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=C:\DataStore\rboard.mdb"

Set CON = Server.CreateObject("ADODB.Connection")
CON.Open strConnect
SQL = "select MAX(b_ref) from MyBoard"
Set RS = CON.Execute(SQL)

If IsNULL(RS(0)) Then
    ref = 1
else
    ref = RS(0) + 1
End If

Set RS = Server.CreateObject("ADODB.RecordSet")
RS.Open "Myboard", strConnect, adOpenStatic, adLockPessimistic, adCmdTable

with RS
    .AddNew
    .Fields("b_name") = name
    .Fields("b_title") = title
    .Fields("b_comment") = comment
    .Fields("b_ref") = ref
    .Fields("b_pos") = 1
    .Fields("b_depth") = 1
    .Update
    .Close
end with
Set RS = nothing
Set CON = nothing
response.redirect "list.asp"
%>