updatecalendar_script.asp

来自「asp日历&备忘录有点像手机的日程表(备忘录)」· ASP 代码 · 共 41 行

ASP
41
字号
<%@ Language=VBScript %>
<%  Option Explicit %>
<% 
' ---------- Page Functions ----------
    Function ChkString(string)
      ChkString = Replace(string, "'", "''")
    End Function

' ---------- Page Variables ----------
    Dim dailyMsg			' The messgae for that day
    Dim dtCurrentDate 			' The current date being updated
    Dim objConn, strConn, strSQL, objRS ' Database Variables

' ---------- Variable Definitions ----------
    dailyMsg = Request("calendarText")
    dtCurrentDate = Request("currentDate")

    Set objConn = Server.CreateObject("ADODB.Connection")
    strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & Server.MapPath("db.mdb") & ";Persist Security Info=False;"
    objConn.Open(strConn)

    ' Check to see if a message exists, if there is update/add it to the db, if not, delete the message
    If Trim(dailyMsg) = "" then
      StrSql = "DELETE FROM calendar WHERE calendarDate = #" & dtCurrentDate & "#"
    Else
      strSQL = "SELECT * FROM calendar WHERE calendarDate = #" & dtCurrentDate & "#"
      Set objRS = objConn.Execute(strSQL)
      If NOT objRS.EOF Then 
        strSQL = "UPDATE calendar SET calendarText = '" & ChkString(dailyMsg) & "' WHERE calendarDate = #" & dtCurrentDate & "#"
      Else
        strSQL ="INSERT INTO calendar (calendarDate, calendarText) VALUES (#" & dtCurrentDate & "#, '" & ChkString(dailyMsg) & "')"
      End If
    End If

    objConn.Execute(strSQL)
    Set objRS = Nothing
    objConn.Close
    Set objConn = Nothing

    Response.Redirect ("calendar.asp?currentDate=" & dtCurrentDate)
%>     

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?