1 / 13

ASP 수행 화면 (1)

ASP 수행 화면 (1). ASP 수행화면 (2). Dbtest.asp(1). <% SQL = "SELECT * FROM TABDBtest " // 열고자 하는 DB 의 내용을 SQL //String 으로 작성 Set adoCONN = Server.CreateObject("ADODB.Connection") // DB 접속을 위한 객체 생성 Set adoRD = Server.CreateObject("ADODB.Recordset") // DB 의 Record 제어를 위한 객체 생성

xiu
Download Presentation

ASP 수행 화면 (1)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ASP 수행 화면(1)

  2. ASP 수행화면(2)

  3. Dbtest.asp(1) • <% • SQL = "SELECT * FROM TABDBtest " //열고자 하는 DB의 내용을 SQL //String으로 작성 • Set adoCONN = Server.CreateObject("ADODB.Connection") // DB접속을 위한 객체 생성 • Set adoRD = Server.CreateObject("ADODB.Recordset") // DB의 Record제어를 위한 객체 생성 • adoCONN.Open "education", "sa", "Jessie" // DB Open • adoRD.Open SQL,adoCONN,1 // 작성한 SQL String으로 record 정보를 Open • if adoRD.BOF or adoRD.EOF then // 해당 Record가 내용이 없을경우 • recordcnt = 0 // recordcnt = 0 • else • recordcnt = adoRD.RecordCount // 그렇지 않으면 recordcnt의 값을 record의 수로 설정 • adoRD.MoveFirst // Record의 위치를 처음으로 설정 • end if • %>

  4. Dbtest.asp(2) • <HTML><HEAD> • <form name="form1" method="post" action="DBtest_insert.asp"> // insert를 위한 Form Start • </HEAD> • <BODY> • <DIV align=center> • <table width="42%" border="1"> • <tr> <td width="22%"> • <div align="center"><b>학번</b></div> • </td> <td width="20%"> • <div align="center"><b>이름</b></div> • </td> <td width="58%"> • <div align="center"><b>전화번호</b></div> • </td> </tr> <tr> • <td width="22%"> • <input name="Stdnum"> // 사용자가 입력하는 학번 String을 Stdnum 으로 설정 • </td>

  5. Dbtest.asp(3) • <td width="20%"> • <input name="Name"> // 사용자가 입력하는 이름 String을 Name 으로 설정 • </td> • <td width="58%"> • <input name="Phonnum"> // 사용자가 입력하는 전화번호 String을 Phonnum 으로 설정 • </td> • </tr> • </table></DIV> • <DIV align=center>&nbsp;</DIV> • <DIV align=center> • <input type="submit" name="inst" value="Insert"> </DIV></FORM>// Insert를 위한 Form End • <form name="form2" method="post" action="DBtest_delete.asp"> // Delete 를 위한 From Start • <table width="293" border="0" align="center" style="WIDTH: 293px; HEIGHT: 29px"> • <tr> • <td> • <div align="left"> • <select name="search" size="1"> • <option selected value="Stdnum">학번</option> // SearchString의 값으로 설정될 내용을 // Stdnum 으로 설정 • <option value="Name">이름</option> // SearchString의 값으로 설정될 내용을 Name으로 설정

  6. Dbtest.asp(4) • <option value="Phonnum">전화번호</option> // SearchString의 값으로 설정될 내용을 Phonnum 으로 • </select> • <input name ="SearchString" size="10" > // Delete.asp로 전달할 parameter의 이름을 SearchString // 으로 정의 • <input type="submit" name="del" value="Delete"> • </div> </td> </tr> • </table> • <div align="center"></div> • </form> // Delete를 위한 Form End • <form name="form2" method="post" action="DBtest_search.asp"> // Search를 위한 Form Start • <table width="293" border="0" align="center" style="WIDTH: 293px; HEIGHT: 29px"> • <tr> • <td> • <div align="left"> • <select name="search" size="1"> • <option selected value="Stdnum">학번</option> // SearchString의 값으로 설정될 내용을 // Stdnum으로 설정 • <option value="Name">이름</option> // SearchString의 값으로 설정될 내용을 Name으로 설정 • <option value="Phonnum">전화번호</option> // SearchString의 값으로 설정될 내용을 Phonnum // 으로 설정 • </select>

  7. Dbtest.asp(5) • <input name ="SearchString" size="10" > // Search.asp로 전달할 parameter의 이름을 SearchString // 으로 정의 • <input type="submit" name="srch" value="Search"> • </div> • </td> • </tr> • </table> • <div align="center"></div> • </form> Search를 위한 From End • <p align="center"><b>&lt;현재 학생 리스트&gt;</b></p> • <table width="42%" border="1" align="center"> • <tr> • <td width="33%"> • <div align="center"><b>학번</b></div> • </td> • <td width="33%"> • <div align="center"><b>이름</b></div> • </td> • <td width="34%"> • <div align="center"><b>전화번호</b></div> • </td> • </tr>

  8. Dbtest.asp(6) • <% // <% asp 문법을 시작하는 기호 • for i = 1 to recordcnt // For Loop 시작 • Stdnum = adoRD("Stdnum") // 변수 Stdnum 에 DB의 Stdnum필드의 내용 입력 • Name = adoRD("Name") // 변수 Name 에 DB의 Name 필드의 내용 입력 • Phonnum = adoRD("Phonnum") // 변수 Phonnum 에 DB의 Phonnum 필드의 내용 입력 • %> • <tr> • <td width="33%" align=center><%=Stdnum%></td> // 변수 Stdnum 의 내용 출력 • <td width="33%" align=center><%=Name%></td> // 변수 Name 의 내용 출력 • <td width="34%" align=center><%=Phonnum%></td> // 변수 Phonnum 의 내용 출력 • </tr> • <% • adoRD.MoveNext // 다음 Record로 이동 • next // 다음 for loop 수행 • %> • </table> • <div align="center"></div> • <p align="center">&nbsp;</p> • </BODY></HTML>

  9. Dbtest_delete.asp • <% • search = request("search") // Form 으로부터 받은 search의 내용을 변수 search 에 저장 • SearchString = request("SearchString") // Form 으로부터 받은 SearchString 의 내용을 변수 // SearchString 에 저장 • // 각각의 내용에 따라 알맞은 SQL String 작정. • if search = "Stdnum" then // search 의 내용이 학번이면 • SQL = "DELETE FROM TABDBtest WHERE Stdnum = " & SearchString • elseif search = "Name" then // search 의 내용이 이름이면 • SQL = "DELETE FROM TABDBtest WHERE Name LIKE '%" & SearchString & "%' " • Else // search 의 내용이 전화번호이면 • SQL = "DELETE FROM TABDBtest WHERE Phonnum LIKE '%" & SearchString & "%' " • end if • Set db = Server.CreateObject("ADODB.Connection") // DB 접속을 위한 객체 생성 • db.Open "education", "sa","Jessie“ // DB Open • db.execute SQL // SQL String 수행 • db.Close // DB Close • Response.Redirect "DBtest.asp" // 초기화면으로 되돌아감 • %>

  10. Dbtest_inserte.asp • <% • Stdnum = request("Stdnum") // Form으로부터 받은 Stdnum의 내용 저장 • Name = request("Name") // Form으로부터 받은 Name 의 내용 저장 • Phonnum = request("Phonnum") // Form으로부터 받은 Phonnum 의 내용 저장 • Set Gdb = Server.CreateObject("ADODB.Connection") // DB 접속을 위한 객체 생성 • Gdb.Open "education", "sa","Jessie“ // DB Open • // Insert를 위한 SQL String 생성 • SQL = "INSERT INTO TABDBtest (Stdnum,Name,Phonnum) VALUES " • SQL = SQL & "(" & Stdnum & "" • SQL = SQL & ",'" & Name & "'" • SQL = SQL & ",'" & Phonnum & "')" • Gdb.Execute SQL // SQL String 수행 • Gdb.Close // DB Close • Response.Redirect "DBtest.asp" // 초기화면으로 되돌아감 • %>

  11. Dbtest_search.asp(1) • <HTML><HEAD> • <% • search = request("search") // Form 으로부터 받은 search의 내용을 변수 search 에 저장 • SearchString = request("SearchString") // Form 으로부터 받은 SearchString의 내용을 변수 // search 에 저장 • if search = "Stdnum" then // search 의 내용이 학번이면 • SQL = "SELECT * FROM TABDBtest WHERE Stdnum LIKE '%" & SearchString & "%' ORDER BY Stdnum " • elseif search = "Name" then // search 의 내용이 이름이면 • SQL = "SELECT * FROM TABDBtest WHERE Name LIKE '%" & SearchString & "%' ORDER BY Name " • Else // search 의 내용이 전화번호이면 • SQL = "SELECT * FROM TABDBtest WHERE Phonnum LIKE '%" & SearchString & "%' ORDER BY Phonnum " • end if • Set adoCONN = Server.CreateObject("ADODB.Connection") • Set adoRD = Server.CreateObject("ADODB.Recordset") • adoCONN.Open "education", "sa", "Jessie" • adoRD.Open SQL,adoCONN,1 • if adoRD.BOF or adoRD.EOF then • recordcnt = 0

  12. Dbtest_search.asp(2) • else • recordcnt = adoRD.RecordCount • adoRD.MoveFirst • end if • %> • </HEAD> • <BODY> • <table width="40%" border="1" align="center"> • <tr> • <td width="33%"> • <div align="center"><b>학번</b></div> • </td> • <td width="33%"> • <div align="center"><b>이름</b></div> • </td> • <td width="34%"> • <div align="center"><b>전화번호</b></div> • </td> • </tr>

  13. Dbtest_search.asp(3) • <% for i = 1 to recordcnt // For Loop 시작 • Stdnum = adoRD("Stdnum") // 변수 Stdnum 에 DB의 Stdnum필드의 내용 입력 Name = adoRD("Name") // 변수 Name 에 DB의 Name 필드의 내용 입력 Phonnum = adoRD("Phonnum") // 변수 Phonnum 에 DB의 Phonnum 필드의 내용 입력 • %> • <tr> • <td width="33%" align=center><%=Stdnum%></td> // 변수 Stdnum 의 내용 출력 • <td width="33%" align=center><%=Name%></td> // 변수 Name 의 내용 출력 • <td width="34%" align=center><%=Phonnum%></td> // 변수 Phonnum 의 내용 출력 • </tr> • <% • adoRD.MoveNext // 다음 Record로 이동 • next // 다음 for loop 수행 • %> • %> • </table> • <div align="center">&nbsp;</div> • <DIV align=center><b><a href="DBtest.asp">뒤로</a><b></DIV></BODY> • </HTML>

More Related