我的一亩三分地 我就喜欢!
13fen  设为主页
 收藏本站
 
当前位置: > 一亩三分地:首页 > 网络学院 > 网络编程 > ASP专区 > Asp技巧/优化 > 普通ASP编辑器 For Access 源代码
热门文章排行
热门文章排行 手推车”功能的实现(10-07)
八大法则防范ASP网站漏洞(10-23)
ASP教程十一、调试ASP脚本(10-23)
在JSP中访问数据库大全(10-23)
虚机服务中常见Asp.Net低级错误一览(03-21)
精采文章排行
精采文章排行 ASP.NET实现抓取网页中的链接(11-15)
ASP连接数据库的11种方法(11-10)
如何动态创建网页的RSS内容摘要(11-10)
ASP网站漏洞及入侵防范方法(11-10)
ASP自定义函数:对字符串正则替换(11-10)
技术专题推荐
网管论坛交流
 

普通ASP编辑器 For Access 源代码 

作者:佚名   来源:一亩三分地   点击:   日期:2007-03-22

<%
    
    ' Generic ASP Editor for Access Tables
    ' Version 1.01 - 9 November 1999
    ' ?Roman Koch
    
    ' =====================================================================
    ' Your customisations go here
    ' =====================================================================
    
    ' Enter the name of the system DSN
    Session("myDSN") = "MP3"
    
    ' Enter the name of the table you want to edit
    ' Note: For text fields, the "Allow Zero Length" attribute must be set to YES
    Session("myTable") = "Customer"

    ' Enter the name of the Primary Key field
    ' Note: The Primary Key MUST be a "Autonumber"-type field
    Session("myKey") = "CustomerID"
    
    ' =====================================================================
    ' End of the customisation section
    ' =====================================================================
    
    Dim objConn
    If isObject(Session("dsnDefined")) Then
        Set objConn = Session("dsnDefined")
    Else
        Set objConn = Server.CreateObject("ADODB.Connection")
        objConn.Open Session("myDSN")
        Set Session("dsnDefined") = objConn
    End If

    strMyOwnPath = Request.Servervariables("PATH_INFO")
    intStart = InstrRev(strMyOwnPath,"/",-1,1)
    strMyName = Mid(strMyOwnPath,intStart+1)
    Session("myName") = strMyName
    
    strAction = Request.Querystring("action")
    lngRecord = Request.Querystring("num")
    
    Select Case strAction
        Case "list" 'list all records
            Call editList()
        Case "update" 'Get the current record and display in a form for editing
            Call editUpdate(lngRecord)
        Case "updateExec" 'Save the changes
            Call editUpdateExec(lngRecord)
        Case "insert" 'Display an empty form for entering a new record
            Call editInsert()
        Case "insertExec" 'Save the new record
            Call editInsertExec()
        Case "delete" 'Display the current record so deletion can be confirmed
            Call editDelete(lngRecord)
        Case "deleteExec" 'Delete the record
            Call editDeleteExec(lngRecord)
        Case Else 'same as list parameter
            Call editList()
    End Select
    
%>

<Script RUNAT="SERVER" LANGUAGE="VBSCRIPT">

'======================================================================
Function editUpdate(lngRecord)
'======================================================================

    strMyTable = Session("myTable")
    strMyKey = Session("myKey")
    strMyName = Session("myName")
    
    sqlQuery = "SELECT * FROM " & strMyTable & " WHERE " & strMyKey & "=" & lngRecord
    Set objRS = objConn.Execute(sqlQuery)
    intFieldCount = objRS.Fields.Count - 1
    
    Response.Write "<html><head><title>Access Table Editor</title>"
    Response.Write "</head><body>"
    Response.Write "<h1>Update Record</h1>"

    Response.Write "<form name=editForm action=" & strMyName & "?action=updateExec&num=" & lngRecord
& " method=POST>"
    Response.Write "<table>"
    For i = 0 To intFieldCount
        strName = objRS(i).Name
        strValue = objRS(i).Value
        Response.Write "<tr><td>" & strName & "</td>"
        If strName = strMyKey Then
            Response.Write "<td><input type=text readonly name=" & strName & " value=""" &
strValue & """></td></tr>"
        Else
            Response.Write "<td><input type=text name=" & strName & " value=""" & strValue
& """></td></tr>"
        End If
    Next

    Response.Write "</table><p> </p><input type=SUBMIT value=Update></form>"
    Response.Write "<p> </p></body></html>"
    
    Set objRS = Nothing

End Function

'======================================================================
Function editUpdateExec(lngRecord)
'======================================================================
    
    strMyTable = Session("myTable")
    strMyKey = Session("myKey")
    strMyName = Session("myName")
    
    sqlQuery = "SELECT * FROM " & strMyTable & " WHERE " & strMyKey & "=" & lngRecord
    Set objRS = objConn.Execute(sqlQuery)
    intFieldCount = objRS.Fields.Count - 1

 

文章评论】 【收藏本文】 【推荐好友】 【打印本文】 【论坛讨论

   相关文章:
·ASP中巧用Response属性 ·第六课:ASP脚本循环语句
·在 Web 页上使用条件数值格式 ·连接数据库查询手册(不仅仅适用于asp)
·警惕"给你的FileSystemObject对象加把锁" ·用ASP做全文检索

   文章评论:(条)
  
 请留名: 匿名评论   点击查看所有评论 网管论坛
 

  责任编辑:一分  声明:刊登此文章是为了传递更多信息,文章内容仅供参考,转载请注明出处。