<form id="hz9zz"></form>
  • <form id="hz9zz"></form>

      <nobr id="hz9zz"></nobr>

      <form id="hz9zz"></form>

    1. 明輝手游網中心:是一個免費提供流行視頻軟件教程、在線學習分享的學習平臺!

      在ASP中用集合成批設置數據庫(二)

      [摘要]二、HTML的集合屬性的應用  下面我們結合一個實際的例子,討論一下如何在ASP頁面中利用HTML的集合屬性來成批操作數據庫,F在我們有一個記錄客戶電子信箱的ACCESS數據庫EMail,其中有一個...

      二、HTML的集合屬性的應用
        下面我們結合一個實際的例子,討論一下如何在ASP頁面中利用HTML的集合屬性來成批操作數據庫,F在我們有一個記錄客戶電子信箱的ACCESS數據庫EMail,其中有一個數據表EmailList,包含CustomerId、CustomerName、CustomerEmail三個字段,分別表示客戶編號、客戶名稱、客戶電子信箱。在ASP頁面SelectId.ASP中,我們采用CheckBox列出所有客戶的客戶名稱(各個CheckBox的值為對應的客戶編號),讓用戶選擇給哪些客戶發送電子郵件。當用戶選擇了客戶并提交數據后,SendMail.ASP將檢索到這些客戶的電子信箱,并給這些客戶發送電子郵件。具體的信息請參見下面ASP程序代碼和注釋信息。

       

      <!-- SelectId.ASP:列出所有客戶的客戶名稱 -->
      <html><head><title>所有客戶的客戶名稱</title></head><body>
      <p align=center><font style="font-family:宋體;font-size:9pt">
      請選擇要給哪些客戶發送“新年問候”的電子郵件
      <form method="POST" action="SendMail.asp">
      <%'建立與ACCESS數據庫的連接
      Set dbConnection = Server.CreateObject("ADODB.Connection")
      dbConnection.open "Driver={Microsoft Access Driver (*.mdb)};"&_
      "DBQ=C:\inetpub\wwwroot\test\Email.mdb"
      '獲取所有客戶的客戶編號、客戶名稱
      Set rsCustomers = Server.CreateObject("ADODB.RecordSet")
      rsCustomers.Open "Select CustomerId,CustomerName,CustomerEmail From EmailList",_
      dbConnection,1,3,1
      '顯示所有客戶的客戶名稱
      while not rsCustomers.eof
      %>
      <br><input type="checkbox" name="CustomerId" value="<%=rsCustomers("CustomerId")%>">
      <a href="mailto:<%=rsCustomers("CustomerEmail")%>">
      <%=rsCustomers("CustomerName")%></a>
      <%rsCustomers.MoveNext
      wend
      rsCustomers.close
      set rsCustomers = nothing
      dbConnection.close
      set dbConnection = nothing
      %>
      <br><input type="submit" value="給客戶發送電子郵件" name="B1"
      style="font-family:宋體;font-size:9pt">
      </form></body></html>

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

      <!-- SendMail.ASP:給所選擇客戶發電子郵件 -->
      <html><head><title>給所選擇客戶發電子郵件</title></head><body>
      <p align=center><font style="font-family:宋體;font-size:9pt">
      正在給下面客戶發送電子郵件
      <%'建立與ACCESS數據庫的連接
      Set dbConnection = Server.CreateObject("ADODB.Connection")
      dbConnection.open "Driver={Microsoft Access Driver (*.mdb)};"&_
      "DBQ=C:\inetpub\wwwroot\test\Email.mdb"
      '獲取所選擇客戶的電子信箱
      Set rsCustomers = Server.CreateObject("ADODB.RecordSet")
      rsCustomers.Open "Select CustomerName,CustomerEmail From EmailList where CustomerId in ("&_
      Request("CustomerId")&")",dbConnection,1,3,1
      while not rsCustomers.eof
      '給一個客戶發電子郵件
      Set myMail = CreateObject("CDONTS.NewMail")
      myMail.From = "sales@test.com"
      myMail.value("Reply-To") = "sales@test.com"
      myMail.To = rsCustomers("CustomerEmail")
      myMail.Subject = "來自王發軍的新年問候"
      myMail.BodyFormat = 1
      myMail.MailFormat = 1
      myMail.Body = "王發軍向"&rsCustomers("CustomerName")&"問好!"
      myMail.Send
      Set myMail = Nothing
      %>
      <br>給<a href="mailto:<%=rsCustomers("CustomerEmail")%>"><%=rsCustomers("CustomerName")%></a>
      發送電子郵件成功!
      <%
      rsCustomers.MoveNext
      wend
      rsCustomers.close
      set rsCustomers = nothing
      dbConnection.close
      set dbConnection = nothing
      %>
      <br>在所選擇的客戶發送電子郵件完畢!
      </body></html>

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

      列出你的所有Session變量

      <%@ Language=VBScript %>
      <% Option Explicit %>
      <%
      Response.Write "在你的程序中一共使用了 " & Session.Contents.Count & _
      " 個Session變量<P>"
      Dim strName, iLoop
      For Each strName in Session.Contents
      '判斷一個Session變量是否為數組
      If IsArray(Session(strName)) then
      '如果是數組,那么羅列出所有的數組元素內容
      For iLoop = LBound(Session(strName)) to UBound(Session(strName))
      Response.Write strName & "(" & iLoop & ") - " & _
      Session(strName)(iLoop) & "<BR>"
      Next
      Else
      '如果不是數組,那么直接顯示
      Response.Write strName & " - " & Session.Contents(strName) & "<BR>"
      End If
      Next
      %>


       





      日韩精品一区二区三区高清