-1

データベースのスクリーンショット

これは、.asp クラシック ページにリンクしようとしているデータベースです。複数のレコードを同じ .asp ページに入力する方法や、必要に応じて特定のレコードをページに入力する方法があるかどうか疑問に思っていました。ASP VBScript を使用しています。データベース (.mdb/.accdb) ファイルからデータを取得しようとしていることに注意してください。

4

1 に答える 1

0
Set conn = Server.CreateObject("ADODB.Connection") 

b_use_dsn = false   
if (b_use_dsn=false) then
    'SQL_server_string = "Provider=SQLOLEDB; Data Source=myMachine; Initial Catalog=pubs; User ID=sa; Password="
    path_to_db = application("path_to_db")
    if (path_to_db = "") then path_to_db = "../data"
    Access_string = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & server.mappath(path_to_db) & "/hotkey.mdb"
else
    Access_string = "DSN=casemodo"
end if
ConnectionString = Access_string
conn.Open ConnectionString

s_table = request.querystring("s_table")
if (s_table="") then s_table = session("s_table")
session("s_table") = s_table

ID_page = request.querystring("ID_page")
if (isnull(ID_page) or ID_page="") then ID_page=session("ID_page")
if (isnull(ID_page) or ID_page="") then ID_page=0
session("ID_page") = ID_page

s_field_order = "i_order"
if (s_table="page_image_stack") then s_field_order = "i_build_image_layer DESC"

on error resume next
'open recordset
s = "SELECT"
s = s & " *"
s = s & " FROM " & s_table
if (ID_page<>"") then
s = s & " WHERE ID_page=" & ID_page
end if
s = s & " ORDER BY " & s_field_order
set rs=conn.execute(s)
if (err.number<>0) then
    if (err.number=-2147217904) then
        s = "SELECT"
        s = s & " *"
        s = s & " FROM " & s_table
        's = s & " ORDER BY ID"
        set rs=conn.execute(s)
    else
        msg = "Error on admin_data_show.asp line 26<hr>s=<br>" & s & "<hr>err.description=" & err.description & "<hr>err.number=" & err.number
        session("msg")=msg
        conn.close
        set conn=nothing
        response.redirect("error_report.asp?send_email=yes")
    end if
end if
i_columns = rs.fields.count

dim array_fields()
redim array_fields(i_columns)

for x=0 to i_columns-1
    s_name = rs(x).name
    array_fields(x) = s_name
    's_fields=s_fields & s_name & ","
    'n_columns = n_columns + 1
next

'Set rs = server.createObject("ADODB.recordset")
'rs.open s, conn, 0, 1 '0=forward only, 1=lock read only

s_main = "Secure Area"
s_title = "Manage data"
%>
<br>Table: <%=ucase(s_table)%>

<table border='0' width='<%=application("n_page_width")%>' cellspacing='0' cellpadding='0'>
<tr>
<td align='center' valign='middle'>
    <table border='0' width='100%' cellspacing='0' cellpadding='0'>
    <tr>
    <td align='left' valign='middle'>
        <br>
        <table border='1' width='100%' cellspacing='0' cellpadding='1' bgcolor='<%=application("s_color_bg_table")%>'>
<%
if (rs.BOF and rs.EOF) then
        Response.Write("<tr>")
        Response.Write("<td colspan='6' align='center'>")
        Response.Write("<table width='70%'>")
        Response.Write("<tr>")
        Response.Write("<td>")
        Response.Write("<br><b>There are no data.<br>Use the menu on the left to add one.</b><br><br>")
        Response.Write("</td>")
        Response.Write("</tr>")
        Response.Write("</table>")
        Response.Write("</td>")
        Response.Write("</tr>")
else
    response.write("<tr>" & vbCrLf)
    response.write("<td align='left' valign='bottom'>edit</td>")
    type_markers=0

    for x=0 to i_columns-1
        response.write("<td align='left' valign='bottom'>")
        s_field = array_fields(x)
        if (len(s_field)>2) then
            part_to_look_at = left(s_field,2)
            if (instr(1,part_to_look_at,"_",1)>0) then
                type_markers = 1
                s_caption = replace(right(s_field,len(s_field)-2),"_"," ")
            else
                s_caption = s_field 
            end if
        else
            s_caption = s_field         
        end if
        s_type=lcase(left(s_field,1)) 'this gives us "s" for string, "d" for date, etc
        response.write(s_caption)
        response.write("</td>" & vbCrLf)
    next
    response.write("<td align='left' valign='bottom'>del</td>") 
    response.write("</tr>" & vbCrLf)

    rs.movefirst
    do while not rs.EOF
        Response.Write("<tr>")

        Response.Write("<td class='small' align='left' valign='top'>")
        Response.Write("<a href='admin_data_add.asp?s_mode=edit&ID=" & rs(0) & "'><img src='images/btn_edit.png' border='0' alt='Edit " & rs(0) & " record'></a>")
        Response.Write("</td>")

        for x=0 to i_columns-1
            response.write("<td class='small' align='left' valign='top'>")
            response.write(rs(x))
            response.write("</td>" & vbCrLf)
        next


        Response.Write("<td class='small' align='left' valign='top'>")
        Response.Write("<a href='admin_data_delete.asp?ID=" & rs(0) & "'><img src='images/btn_delete.gif' border='0' alt='Delete this record'></a>")
        Response.Write("</td>")

        Response.Write("</tr>")

        rs.MoveNext
    loop
end if
rs.close
set rs = nothing
conn.close
set conn=nothing
%>
        </table>

    </td>
    </tr>
    </table>
</td>
</tr>
</table><br>
于 2013-04-17T02:54:37.183 に答える