+++ ȨÁ¦ÀÛ ¹ÙÀ̺í +++
ȨÁ¦ÀÛ ¹ÙÀ̺í ÀÌ »çÀÌÆ®´Â ÀÌ¿µÂù´ÔÀÇ »çÀÌÆ®¸¦ º¹¿øÇÑ °ÍÀÔ´Ï´Ù.
Untitled Document
Html
Dhtml
Css
Php
Asp
Cgi
Java Script
Java Applet
Multimedia
Win Tip
°Ô½ÃÆǸ¸µé±â (2) - ±Û¾²±â
(1) Write.asp ¹®¼­ ¸¸µé±â

ÀÏ´ÜÀº °£´ÜÇÏ°Ô ¹æ¹®ÀÚ¿¡°Ô À̸§°ú Á¦¸ñ ±×¸®°í ±ÛÀÇ ³»¿ëÀ» ÀÔ·ÂÇϵµ·Ï ÇÏ´Â ¹®¼­¸¦ ¸¸µç´Ù. ÀÌ°÷¿¡ ±âÀÔÇÑ ³»¿ëÀÌ Access DB¾È¿¡ ÀúÀåµÈ´Ù. Method ºÎºÐÀ» Post·Î ±âÀÔÇÏ°í action ºÎºÐ¿¡¼­ Insert.asp ¹®¼­¸¦ ÁöÁ¤ÇÑ°Í¿¡ °ü½ÉÀ» °¡Áø´Ù.

<html>
<head><title>±Û¾²±â</title></head>
<body>

    <form method='POST' action='Insert.asp'>
    <table border='1' width='400'>
    <tr>
    <td width='170' 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='cente' >±Û</td>
    <td>
    <textarea wrap='hard' rows='10' name='comment' cols='50'></textarea>
    </td>
    </tr>
    <tr>
    <td align='right' colspan='2' style='padding-right:25'>
    <input type='submit' value='±Û ÀúÀå'>
    </td></tr>
    </table>
    </form>

</body>
</html>


¼Ò½º´ë·Î ¿Ï¼ºÇÏ°í ÀÌ°ÍÀ» write.asp ¹®¼­·Î ÀúÀåÇÑ ÈÄ¿¡ ºê¶ó¿ìÀú·Î È®ÀÎÇÑ ¸ð½ÀÀÌ´Ù.



(2) Insert.asp ¹®¼­ ¸¸µé±â

Write.asp ¹®¼­ action ºÎºÐ¿¡¼­ ÁöÁ¤ÇÑ Insert.asp ¹®À» ´ÙÀ½°ú °°ÀÌ ÀÛ¼ºÇÑ´Ù.

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

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

Dim strConnect,Dim objRS
strConnect="Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=C:\DataStore\board.mdb"
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
    .Update
    .Close
end with
Set objRS = nothing
Response.Write "insert ok"
%>


(3) ¼³¸í

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


-- ADO »ó¼ö°¡ Á¤ÀǵǾú´Â ÆÄÀÏÀ» ÁöÁ¤


Option Explicit


-- º¯¼öÀÇ ¸í½ÃÀû ¼±¾ð ¹æ¹ý¿¡ ÀÖ¾î º¯¼ö »ç¿ë½Ã »ý±æ ¼ö ÀÖ´Â ¿ÀŸ¸¦ Àâ´Â´Ù


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


-- write.html ¹®¼­¿¡¼­ Method=Post·Î ÇßÀ¸¹Ç·Î Àü´ÞµÈ Äõ¸® °ªÀº Æû ÄÝ·º¼Ç¿¡¼­ ¾òÀ» ¼ö ÀÖ´Ù. ÀÌ°ÍÀ» »õ·Î¿î Áö¿ª º¯¼ö¿¡ °¢°¢ ÀúÀåÇÑ´Ù.


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


-- DB¿¡ ¿¬°áÇϴµ¥ ÇÊ¿äÇÑ ÄÜ³Ø¼Ç ½ºÆ®¸µ °ªÀ» Àû´Â´Ù. Data Source ºÎºÐ¿¡ ¿ì¸®°¡ ¸¸µé¾ú´ø board.mdb¸¦ ÁöÁ¤ÇÑ´Ù.


Set objRS = Server.CreateObject("ADODB.RecordSet")


-- ADO °³Ã¼ RecordSet °³Ã¼ÀÇ ÀνºÅϽº¸¦ »ý¼ºÇÑ´Ù


objRS.Open "Myboard", strConnect, adOpenStatic, adLockPessimistic,adCmdTable


-- Open ¸Þ½îµå¸¦ ÀÌ¿ëÇÏ¿© ·¹ÄÚµå¼Â¿¡ Á¢±ÙÇÑ´Ù. ÀÎÀÚ°ª 5°³°¡ ÁÖ¾îÁö´Âµ¥ ù ¹ø°´Â ¿ì¸®°¡ ¸¸µé¾ú´ø board.mdbÀÇ Å×À̺íÀ̸§À» Àû¾îÁÖ°í µÎ ¹ø°´Â ÄÜ³Ø¼Ç ½ºÆ®¸µ°ªÀ» Àû¾îÁÖ°í ¼¼ ¹ø°´Â Ä¿¼­Å¸ÀÔ, ³× ¹ø°´Â ¶ô ŸÀÔÀ» Àû¾îÁØ´Ù.  ´Ù¼¸ ¹øÀç´Â ¿É¼ÇºÎºÐÀ¸·Î ¾î´À ŸÀÔÀÇ µ¥ÀÌÅÍ ¼Ò½ºÀÎÁö ¾Ë·ÁÁØ´Ù.


with objRS
    .AddNew
    .Fields("b_name") = name
    .Fields("b_title") = title
    .Fields("b_comment") = comment
    .Update
    .Close
end with


-- with ¹®À» »ç¿ëÇÏ¸é °´Ã¼ÀÇ À̸§À» ¾²Áö ¾Ê¾Æµµ µÈ´Ù. AddNew ·Î »õ·Î¿î Á¤º¸¸¦ ÀÔ·ÂÇÏ°Ú´Ù´Â °ÍÀ» ¾Ë¸®°í °¢°¢ÀÇ ÇʵåÀ̸§À» Àû°í ±×¿¡ ÇØ´çÇÏ´Â °ªÀ» Àû¾îÁØ´Ù. Update ·Î ÀÔ·ÂµÈ Á¤º¸¸¦ ¾÷µ¥ÀÌÆ®Ç϶ó°í ¸í·ÉÇÑ´Ù. Close·Î ´Ý´Â´Ù.


Set objRS = nothing
Response.Write "insert ok"


-- °³Ã¼ÀÇ ÀνºÅϽº°ªÀ» ¾ø¾Ö°í insert ok ¶ó´Â ¸Þ¼¼Áö¸¦ Ãâ·Â½ÃŲ´Ù.


(4) È®ÀÎ

ºê¶ó¿ìÀú·Î write.asp ¹®¼­¸¦ ·ÎµùÇÑÈÄ¿¡ Àû´çÇÑ ±ÛÀ» ÀÔ·ÂÇÑÈÄ Àü¼Û¹öÆ°À» ´©¸¥´Ù. Á¦´ë·Î DB¿¡ ÀúÀåÀÌ µÇ¾ú´Ù¸é È­¸é¿¡ 'insert ok'¶ó´Â ¸Þ¼¼Áö°¡ ³ª¿Â´Ù. ±×·³ ¼º°ø. Á¤¸»·Î µðºñ¿¡ ÀúÀåÀÌ µÇ¾ú´ÂÁö È®ÀÎÇÑ´Ù.

access¸¦ ½ÇÇà½ÃÅ°°í ¾Æ±î ÀúÀåÇß´ø board.mdb¸¦ ¿¬ÈÄ Myboard Å×À̺íÀ» ¼±ÅÃÇÏ¿© ³»°¡ ÀÔ·ÂÇÑ ±ÛÀÌ Á¤È®ÇÏ°Ô ÀúÀåµÇ¾ú´ÂÁö È®ÀÎÇÑ´Ù.
Update : 2001/05/29 [µ¹¾Æ°¡±â]