473,387 Members | 1,549 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Update Form and use RS to generate CDO Email

5
Hi All,
I am trying to send an automatic email when an update has been made.
My update statement will updates 6 fields, and dependant on one of the fields, I would like to send an email using CDO.
Once the update is made, I am trying to re-query the database to retrieve all the fields that need to be included in the email, but it's just not working for me!!

This my code to update

Expand|Select|Wrap|Line Numbers
  1. <%
  2. Set Conn = Server.CreateObject("ADODB.Connection")
  3. conn.Provider="Microsoft.Jet.OLEDB.4.0"
  4. conn.Open "c:/inetpub/wwwroot/change control.mdb"
  5.  
  6.  
  7.  
  8.  
  9. strSQL = "UPDATE tblform SET" & _
  10.     " PCM = " & "'" & Replace(Request.Form("PCM"),"'","''") & "'" & _
  11.     ", PCMAction = " & "'" & Request.Form("PCMAction") & "'" & _
  12.     ", PCMReason = " & "'" & Replace(Request.Form("PCMReason"),"'","''") & "'" & _
  13.     ", Approve1 = " & "'" & Request.Form("Approve1") & "'" & _
  14.     ", 1Action = " & "'" & Request.Form("1Action") & "'" & _
  15.     ", 1Reason = " & "'" & Replace(Request.Form("1Reason"),"'","''") & "'" & _
  16.     ", Approve2 = " & "'" & Request.Form("Approve2") & "'" & _
  17.     ", 2Action = " & "'" & Request.Form("2Action") & "'" & _
  18.     ", 2Reason = " & "'" & Replace(Request.Form("2Reason"),"'","''") & "'" 
  19.  
  20.     IF Request.Form("2Action") <> "" THEN
  21.     strSQL=strSQL & ", Status = '"& Request.Form("2Action") &"' "
  22.     End If
  23.     strSQL = strSQL & " WHERE ccf = " & Request.Form("ccf") & ";"
  24.  
  25. Conn.execute(strSQL)
  26.  
  27. idOfUpdatedRecord = Request.Form("CCF")
  28. %>
  29.  
  30. <CENTER><H2>
  31. <font face="InfoText Bd" color="#0388BB">Thank you, the status of Change <% = idOfUpdatedRecord %> has been successfully updated.</font></H2>
  32. <%Conn.Close%>
Expand|Select|Wrap|Line Numbers
  1. This is my code to the query the database to retrieve all the details from the database and then use this to email:
  2.  
  3.  
  4. Code:
  5. <% IF Request.Form("2Action")="Approved" or Request.Form("2Action")="Rejected" THEN
  6. Set Conn = Server.CreateObject("ADODB.Connection")
  7. conn.Provider="Microsoft.Jet.OLEDB.4.0"
  8. conn.Open "c:/inetpub/wwwroot/change control.mdb"
  9. set rs=Server.CreateObject("ADODB.recordset")
  10. ' Set SQL statement
  11. SQL = "SELECT * FROM tblform WHERE ccf = " & Request.Form("ccf") & " "
  12.  
  13. ' Open Recordset Object
  14. rs.Open strSQL,conn
  15.  
  16.  
  17.  
  18.  
  19.  
  20. DIM strEmail, strOriginator, strOriginEmail, StrRep, strStartDate, strCCF, strBody, strStatus
  21. strEmail=RS("Email")
  22. strOriginator=Request.Form("Originator")strOriginEmail=Request.Form("Originator_Email")
  23. strRep=Request.Form("Rep")
  24. strSummary=Request.Form("Summary")
  25. strImplementer=Request.Form("Implementer")
  26. strStartDate=Request.Form("StartDate")
  27. strStatus=Request.Form("2Action")
  28. strStart=Request.Form("Start")
  29. strRisk=Request.Form("Risks")
  30. strCCF= Request.Form("CCF")
  31. strBody="<font size=3 face=Helvetica Neue color=#0388BB>" & "<strong>" & "CCF " & strCCF & " has been " & strStatus & "<br>" & "<br>" 
  32. strBody=strBody & "<font size=2 face=Helvetica Neue color=#260063>" & "<strong>"& "Start Date: " & strStartDate & "<br>" 
  33. strBody=strBody & "Start Time: " & strStart & "<br>"  
  34. strBody=strBody & "Change Summary: "  & strSummary & "<br>"  
  35. strBody=strBody & "Implementer: " & strImplementer & "<br>" & "<br>" & "<br>" 
  36. strBody=strBody & "<font size=3 face=Helvetica Neue color=#0388BB>" & "<strong>" & "Please contact Change@xxxx.com if you require further information" & "<br>" 
  37. strBody=strBody & "or Click here to view full details " & "<a href=http://127.0.0.1/view.asp?qryid="& StrCCF & ">"& strCCF & "</a>"
  38.  
  39.  
  40. Set Mail=Server.CreateObject("CDO.Message")
  41. 'Next lines of code are for XP PWS only:
  42. Set Config = CreateObject("CDO.Configuration") 
  43.  
  44.  'Configuration: 
  45.  Config.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing")  = 1
  46.  Config.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") _
  47.   = "c:\inetpub\mailroot\pickup" 
  48.  
  49.  
  50.  'Update configuration 
  51.  Config.Fields.Update 
  52.  Set Mail.Configuration = Config 
  53.  
  54. Mail.From="Change@xxxxx.com"    
  55. Mail.To="changex@xxxxx.com;"& strOriginEmail & ";" & strEmail
  56. Mail.CC=strRep
  57. Mail.Subject="CCF " & strCCF & " has been "  & strStatus 
  58. Mail.HTMLBody=strBody 
  59. Mail.Send
  60. Set Mail=Nothing
  61. End If
  62. Conn.Close
  63. %>
If I query the database and try to use RS, I get the ADODB.Recordset (0x800A0CC1)
Item cannot be found in the collection corresponding to the requested name or ordinal.
/approval.asp, line 46 error
I do not get an error if I use Request.Form, but then there is no data populated for the email with the exception of the status and the ID number because they were request.form update fields!

I have checked for spelling errors when using RS, but still receive the
ADODB.Recordset (0x800A0CC1)
Item cannot be found in the collection corresponding to the requested name or ordinal.
/approval.asp, line 46 error
Thanks in advance for any help! :confused:
Jul 24 '06 #1
2 2832
sashi
1,754 Expert 1GB
Hi there,

"ADODB.Recordset (0x800A0CC1)
Item cannot be found in the collection corresponding to the requested name or ordinal"

this error message means that one ore more field name is not found or not same in your table.. check your field names once again.. good luck my fren.. take care.. :)
Jul 25 '06 #2
devine
5
Hi there,

"ADODB.Recordset (0x800A0CC1)
Item cannot be found in the collection corresponding to the requested name or ordinal"

this error message means that one ore more field name is not found or not same in your table.. check your field names once again.. good luck my fren.. take care.. :)
Many thanks Sashi,

The problem was with this line of code:

Expand|Select|Wrap|Line Numbers
  1. SQL = "SELECT * FROM tblform WHERE ccf = " & Request.Form("ccf") & " "
  2.  
  3. ' Open Recordset Object
  4. rs.Open strSQL,conn
I have changed StrSQL to match SQL and now everything works great!
Jul 25 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Mark | last post by:
A beginner in this area, I have been able to read a record from a MySQL database and populate an HTML form (wow!). Now, my goal is to allow the user to edit the contents of the form and then...
3
by: laurie | last post by:
Hi all, I'm trying to help out a friend who has inherited a client with a PHP shopping cart application. Neither of us know PHP, but I've been muddling my way through, trying to get these old...
2
by: Colin Steadman | last post by:
Part No Description Quantity 45643 Random part 10 45678 Another Random part 7 98944 And another 1 <submit button> ...
16
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
6
by: Robert | last post by:
Hello, Accessors What I would like to do is create a multi-record table update. I have a table and a form for it. I want to modify it so that there is a new field (textbox) (not bound to a...
2
by: Joe Fetters via .NET 247 | last post by:
Have googled and read the VS.NET documentation can't seem to getthe answer to the following. Environment: Framework 1.1 VB.NET WinForm Access database Using all automagic tools (DataAdapter...
3
by: Simon | last post by:
Hi everyone, I have a small problem regarding a wizard that I'm making on my website. The wizard is obviously a series of pages that take values from the user. My question is: - Should I...
5
by: Stephen Plotnick | last post by:
I'm very new to VB.NET 2003 Here is what I have accomplished: MainSelectForm - Selects an item In a public class I pass a DataViewRow to ItemInformation1 Form ItemInformation2 Form
5
by: =?Utf-8?B?UlBhcmtlcg==?= | last post by:
I used the wizard to generate a typed dataset for my table and let it create my SPROCs. It created everything, and the GetData() method and the custom GetByUserName query works great, but when I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.