<%
strConnect="Provider=Microsoft.Jet.OLEDB.4.0;" & _
           "Data Source=C:\DataStore\rboard.mdb"
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open strConnect
SQL = "select * from MyBoard order by b_ref desc,b_pos"
Set objRS = objConn.Execute(SQL)

Response.Write "" &_
"<table border=1 width=500>" & _
"<tr>" & _
"<td align=center>번호</td>" & _
"<td align=center>이름</td>" & _
"<td align=center>제목</td>" & _
"</tr>"

Dim i
Do while Not objRS.EOF
    Response.Write "<tr>" &_
    "<td align=center>" & objRS("b_key") & "</td>" & _
    "<td align=center>" & objRS("b_name") & "</td>" & _
    "<td>"

    if objRS("b_depth") > 1 then
        For i = 1 to objRS("b_depth")
            Response.Write "  "
        Next
    end if
    Response.Write "<a href=./read.asp?key=" & objRS("b_key") & ">" & _
    objRS("b_title") & "</a></td>" & _
    "</tr>"
    objRS.MoveNext
Loop
Set objRS = nothing
Response.Write "<tr><td colspan=3 align=center>" & _
    "<a href=./write.asp>글쓰기</a></td></tr>" & _
    "</table>"

%>




<%

key=Request("key")
strConnect="Provider=Microsoft.Jet.OLEDB.4.0;" & _
           "Data Source=C:\DataStore\rboard.mdb"
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open strConnect
SQL = "select * from MyBoard where b_key Like " & key
Set objRS = objConn.Execute(SQL)

comment=objRS("b_comment")
Response.Write "<table border=1 width=400><tr><td>" & comment & "</td></tr></table>"
Response.Write "<table border=0 width=400><tr><td align=center>" & _
               "<a href=./replay.asp?key=" & key & ">답장</a></td></tr></table>"
Set objRS = nothing
Set objConn = nothing

%>




<%
key=Request("key")
strConnect="Provider=Microsoft.Jet.OLEDB.4.0;" & _
           "Data Source=C:\DataStore\rboard.mdb"
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open strConnect
SQL = "select * from MyBoard where b_key Like " & key
Set objRS = objConn.Execute(SQL)

name=objRS("b_name")
title=objRS("b_title")
comment=objRS("b_comment")
ref=objRS("b_ref")
pos=objRS("b_pos")
depth=objRS("b_depth")

Response.Write "" & _
"<form method=POST action=replay_up.asp>" & _
"<input type=hidden name=key value=" & key & ">" & _
"<input type=hidden name=ref value=" & ref & ">" & _
"<input type=hidden name=pos value=" & pos & ">" & _
"<input type=hidden name=depth value=" & depth & ">" & _
"<table border=1 width=400>" & _
"<tr>" & _
"<td align=center>제목</td>" & _
"<td><input type=text name=title size=50 value=" & title & "></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>" & comment & "</textarea></td>" & _
"</tr><tr>" & _
"<td align=right colspan=2>" & _
"<input type=submit value=글저장>" & _
"</td></tr></table>" & _
"</form>"
Set objRS = nothing
Set objConn = nothing

%>




<!--METADATA TYPE= "typelib"  NAME= "ADODB Type Library"
      FILE="C:\Program Files\Common Files\SYSTEM\ADO\msado15.dll"  -->
<%
Dim key,ref,pos,depth,name,title,comment
key=Request("key")
ref=Request.form("ref")
pos=Request.form("pos")
depth=Request.form("depth")
name=Request.form("name")
title=Request.form("title")
comment=Request.form("comment")

strConnect="Provider=Microsoft.Jet.OLEDB.4.0;" & _
           "Data Source=C:\DataStore\rboard.mdb"
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open strConnect
SQL = "Update Myboard set b_pos = b_pos+1 where b_ref=" & ref & " and b_pos > " & pos
objConn.Execute(SQL)

Response.write ref & pos & depth & "<br>"

new_pos= CInt(pos)+1
new_depth= CInt(depth)+1

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

with objRS
    .AddNew
    .Fields("b_name") = name
    .Fields("b_title") = title
    .Fields("b_comment") = comment
    .Fields("b_ref") = ref
    .Fields("b_pos") = new_pos
    .Fields("b_depth") = new_depth
    .Update
    .Close
end with

Set objRS = nothing
Set objConn = nothing
Response.redirect "list.asp"

%>