DSN 연결하기
제어판 -> 관리도구 -> ODBC 데이터 원본(64비트) -> 시스템DNS -> 추가
1. frame 만들기
<frameset rows="80%,*">
<frame src="cread.asp">
<frame src="cwrite1.asp">
</frameset>
2.cwrite1.asp (하단 프레임 쓰기 버튼)
<html>
<body>
<form method="post" action="cwrite2.asp">
<table border="2">
<tr>
<td>Chat:</td>
<td><input type="text" name="txtIdea" size="47"</td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="btnsubmit" value="Submit"></td>
</tr>
</table>
</form>
</body>
</html>
3.cwrite2.asp (쓰기동작)
<html>
<body>
<%
X1 = Request.Form("txtIdea")
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.ConnectionString = "DSN=chat.dsn"
Conn.Open
SQL = "INSERT INTO IdeaTime (Idea) VALUES ('"&X1&"')"
Conn.Execute SQL
Conn.close
Set Conn=nothing
Response.Redirect "cwrite1.asp"
%>
</body>
</html>
쓰고나서 원위치로 되돌리는 코드
Response.Redirect "cwite1.asp"
4. cread.asp
<html>
<head>
<meta http-equiv = "Refresh" content="3">
</head>
<body>
<%
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.ConnectionString = "DSN=chat.dsn"
Conn.Open
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.Open "Select * From IdeaTime Order By id Desc", Conn
%>
<table border="0" width="670">
<tr bgcolor="gray">
<td width="155" height="11">
<p><b>Chat</b></p>
</td>
</tr>
<%
while not Rs.eof
%>
<tr>
<td width="155" height="3">
<p><%=Rs("Idea")%></p>
</td>
</tr>
<%
Rs.movenext
Wend
Rs.close
set Rs=nothing
Conn.close
Set Conn=nothing
%>
</body>
</html>
실시간으로 채팅 3초마다 리프레쉬
<meta http-equiv = "refresh" content="3">
뜨는 순서
Order By id Desc //내림차순 오름차순은Ace