2016-10-02 3 views
0

웹 사이트의 테이블을 채우기 위해 "select"문에서 특정 요소를 추출하려고합니다. 나는 Classic ASP를 사용할 것이다.레코드 세트의 특정 요소 찾기, 클래식 ASP

예를 들어, 아래의 선택 문은이 값을 반환합니다.

알렉스 Alex123이

이제 내 웹 페이지에, 나는 테이블이 같은 것을보고 싶지 이름 ID,

이름 닉네임 ID 주소 알렉스 "입력 필드"Alex123 "입력 필드"

내 HTML 코드에서 나는 이런 식으로 할 것을 기대하고 있습니다. 내가 어떻게 할 수 있니?

<tr> 
<td> "some code to extract "Alex" from the recordset"</td> 
<td> <input blalbalba> </td> 
<td> "some code to extract "Alex123" from the recordset"</td> 
<td> <input blabalba> </td> 
</tr> 

다음은 내 연결 문자열과 선택 문입니다.

Set Con = CreateObject("ADODB.Connection") 
Con.ConnectionString = "Provider=SQLOLEDB;Data Source=YOONGTAT\SQLEXPRESS;Database=testing;User ID=sa;password=1234" 
Con.open 

set rs=Server.CreateObject("ADODB.Recordset") 
rs.Open "Select * from dbo.exampletable where user_name like '%" & Request.Form("employeeName[]")(i) & "%' and user_id like '%" & Request.Form("employeeId[]")(i) & "%'" , con 
+0

이것은 아마도 당신이 찾고있는 것입니다 : http://stackoverflow.com/questions/13405736/classic-asp-to-pull-data-from-database –

답변

0

당신은 당신이에 관심이있는 어떤 필드 값을 철수하고 적절한 HTML과 인라인을 인쇄, 레코드를 통해 루프 필요합니다. 이 같은 일이 트릭을해야합니다 :

<table> 
    <thead> 
    <tr> 
     <th>Name</th> 
     <th>Nickname</th> 
     <th>ID</th> 
     <th>Address</th> 
    </tr> 
    </thead> 
<% 
    rs.Open "Select * from dbo.exampletable where user_name like '%" & Request.Form("employeeName[]")(i) & "%' and user_id like '%" & Request.Form("employeeId[]")(i) & "%'" , con 
    do while not rs.BOF and not rs.EOF 
    Response.Write("<tr>") 
    Response.Write("<td>" & rs("NameFieldName") & "</td>") 
    Response.Write("<td><input type=""text"" id=""nickname""></td>") 
    Response.Write("<td>" & rs("IdFieldName") & "</td>") 
    Response.Write("<td><input type=""text"" id=""address""></td>") 
    Response.Write("</tr>") 
    rs.MoveNext 
    loop 
    rs.Close 
%> 

죄송합니다 내 구문은 조금있다. Classic ASP를 작성한 이후 오랜 시간이 걸렸습니다. :) 실제 이름이 무엇이든간에 데이터베이스 필드 이름을 변경해야합니다. 입력 필드를 정확히 찾고 있는지 잘 모르겠습니다. 따라서 적절하게 조정하십시오.하지만이 작업으로 충분할 것입니다. .