database connections and .asa files

Discussion in 'Classic ASP' started by cake, Jan 20, 2007.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Hi,

    Since I moved to discountasp (I am generally very happy with their service) mySession_OnEnd call no longer returns my email. What happens, is that when a user drops a session if they have anything in their cart, the contents, with their contact details, are sent to the sales team.

    As I said, this worked fine before, andif I copy the code into another page and fire it off, it works fine, but not within the .asa file, what could be causing this, and how do I fix it? Anyway, here is the code:

    Sub Session_OnEnd
    If Session("tItemsInCart") > 0 Then

    'Set up the variables
    Dim objConn
    Dim objRS
    Dim strSQL
    Dim itemString
    Dim orderString
    Dim titleHolder

    'Create my connection
    Set objConn = Server.CreateObject("ADODB.Connection")
    objConn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("my connection string .mdb")
    Set objRS = Server.CreateObject("ADODB.Recordset")

    'build thesql string
    strSQL = "SELECT Order.OrderID, OrderDetails.ProductID, Product.BandFilm, Product.ArtistThe, " _
    & "Product.Title, Product.Category, Product.Dimensions, Product.WholesalePrice, Category.DisplayType, OrderDetails.Qty " _
    & "FROM Category INNER JOIN (Product INNER JOIN ([Order] INNER JOIN OrderDetails ON " _
    & "Order.OrderID = OrderDetails.OrderID) ON Product.ProductID = OrderDetails.ProductID) " _
    & "ON Category.CategoryID = Product.Category WHERE (((Order.OrderID)= " & Session("OrderID") & ")) ORDER BY Product.Category;"

    'retrieve the records
    objRS.Open strSQL, objConn

    'build the order string, formatted for the email
    Do While Not objRS.EOF

    if objRS("Title")>"" Then
    titleHolder = objRS("Title")
    Else
    titleHolder = " "
    End if

    itemString = objRS("ProductID")& " " & objRS("Qty") & " " & objRS("ArtistThe") & " " & objRS("BandFilm") _
    & " " & titleHolder & " " & objRS("DisplayType") & " " & objRS("Dimensions") _
    & " @" & FormatCurrency(objRS("WholesalePrice"), 2) & " " & VbCrLf

    orderString = orderString + itemString
    objRS.MoveNext
    Loop

    'cleanup database connection
    objRS.Close
    Set objRS = Nothing
    objConn.Close
    Set objConn = Nothing
    set objMessage = createobject("cdo.message")
    set objConfig = createobject("cdo.configuration")

    ' Setting the SMTP Server
    Set Flds = objConfig.Fields
    Flds.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    Flds.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
    Flds.update
    Set objMessage.Configuration = objConfig
    objMessage.To = "my email"
    objMessage.From = "sales team"
    objMessage.Subject = "Timeout Cart for: " & Session("theShop")
    objMessage.TextBody = "Shop: " & Session("theShop") & VbCrLf _
    & "User ID: " & Session("UserID") & VbCrLf _
    & "Password: " & Session("PWord") & VbCrLf _
    & orderString
    objMessage.fields.update
    objMessage.Send

    set objMessage = nothing
    set objConfig = nothing
    End If
    End Sub
    As I said, it worked before, and if I copy it into another page it works, strange... I have read somestuff saying that it 'could' be the connection causing the problem, but of course it is hard to generate error messages for.asa files as this is really a background process! Any help really appreciated.

    R</CODE>
     
  2. Hi, thanks for the reply

    I looked through the links, but it is not the email portion of the procedure that I am having the problem with - that works fine if I pull the database connection out, it is that that seems to be causing the problem, but does not throw and error as such!

    But I will look further, and thanks, Ron
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page