Wrox Programmer Forums
|
ASP CDO As of Oct 5, 2005, this forum is now locked. No posts have been deleted. Please use "Classic ASP Professional" at: http://p2p.wrox.com/forum.asp?FORUM_ID=56 for discussions similar to the old ASP Pro Code Clinic or one of the other many remaining ASP and ASP.NET forums here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP CDO section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 12th, 2004, 03:53 PM
Authorized User
 
Join Date: Mar 2004
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to stellabantug
Default converting CDONTS to CDOSYS

Hi all!! Im trying to convert my CDONTS code to CDOSYS because we just converted to Windows Server 2003. Below is the code that I've changed based on research. I am not really a programmer, but I think I followed all the instructions as accurately as I can. Can you guys take a look and let me know what I am doing wrong. Thanks!


Dim objCDOSYSMail
Dim objConf
Dim strFrom
Dim strTo
Dim strCc
Dim strBcc
Dim strSubject
Dim strBody

strFrom=Request.Form("ReqEmail")& "@advocatehealth.com"
strTo="[email protected]"
strSubject = "Research Request Confirmation Page"
strBody="The following information was submitted:" & Chr(13) & Chr(13)

If Trim(Request.Form("Contact_FullName"))<>"" Then
   strBody = strBody & "Requestor's Name: " & Request.Form("Contact_FullName") & Chr(13)
End If

If Trim(Request.Form("Site"))<>"" Then
   strBody = strBody & "Site: " & Request.Form("Site") & Chr(13)
End If

Note: This goes on until the last of the fields - I cut the rest of it to make it shorter.


strBody = strBody & Chr(13) & Chr(13) & "Thank you for submitting your data."

strCc=Request.Form("VPEMail") & "@advocatehealth.com"
strBcc=Request.Form("ReqEmail") & "@advocatehealth.com"

Set objConf = Server.CreateObject("CDO.Configuration")

Const cdoSendUsingPort = 25
Dim objFields

Set objFields = objconf.Fields

objFields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
objFields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "moat.advocatehealth.com"
objFields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10

objFields.Update

Set objCDOSYSMail.Configuration = objConf

Set objCDOSYSMail = Server.CreateObject("CDO.Message")
objCDOSYSMail.From=strFrom
objCDOSYSMail.To=strTo
objCDOSYSMail.Cc=strCc
objCDOSYSMail.Bcc=strBcc
objCDOSYSMail.Subject=strSubject
objCDOSYSMail.TextBody=strBody

objCDOSYSMail.Send

Set objCDOSYSMail = Nothing
Set objConf = Nothing
Set objFields = Nothing




%>
<p><b>Thank you for submitting your
Research Request!<br>
</b>You will receive an e-mail
shortly.&nbsp; The e-mail was sent using the following information:</p>
<b>Sent To: <% '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%
   Response.Write Request.Form("ReqEmail") & "@advocatehealth.com"
  '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%
%>
<br>
From&nbsp;&nbsp;&nbsp; : Research Team
<p>Subject: Research Request Confirmation Page</p>
<p>Content: <% '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%
' Call the ParseBody function and pass the strBody string to it.
' This will replace the Chr(13) characters with <br> tags in the HTML.
Response.Write(ParseBody(strBody))
  '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%
%>
</p>

<p>&nbsp;</p>
</b>

 
Old March 13th, 2004, 05:36 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Stella,

Can you provide more information? Are you getting an error? If so, can you provide the error details?
It's hard to fix a problem if we don't know what the problem is....

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old March 16th, 2004, 01:30 PM
Authorized User
 
Join Date: Mar 2004
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to stellabantug
Default

Imar

Actually, I think I may have found the solution to this through the help of another programmer friend. He simplified the configurations and also took out and replaced the "Parsebody" function that I have on my code.

I have got a new problem though. I think the rest of my code is okay, but now I am getting this error message:

Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

/OnlineForm/Email1.asp, line 57

The DSN is properly configured and I dont know why this error message is showing up. Can anyone help?

THANKS MUCH!


 
Old March 16th, 2004, 01:43 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Can you provide the code for the part that throws the error?

This usually indicates an incorrectly setup connection string. Are you sure about the DSN?

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old March 16th, 2004, 02:32 PM
Authorized User
 
Join Date: Mar 2004
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to stellabantug
Default

Here is the code

Dim myConnString
Dim myConnection
Dim mySQL

myConnString = Application("SampDatabConn_ConnectionString")
Set myConnection = Server.CreateObject("ADODB.Connection")
myConnection.Open myConnString

mySQL= "INSERT INTO ResearchInfo "
mySQL= mySQL & "(Name,Site,ReqEmail,VPEmail) "
mySQL= mySQL & "VALUES ('" & Replace(Request.Form ("Contact_FullName"), "'","''") & "'"
mySQL= mySQL & ",'" & Replace(Request.Form("Site"), "'", "''") & "'"
mySQL= mySQL & ",'" & Replace(Request.Form("ReqEmail"), "'","''") & "'"
mySQL= mySQL & ",'" & Replace(Request.Form("VPEmail"), "'", "''") & "'" & "')"


myConnection.Execute mySQL
myConnection.Close
Set myConnection = Nothing



The DSN is setup and is listed on the "System DSN" list.



 
Old March 16th, 2004, 04:51 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Right. Can you try two things for me? Add the following code to the page, run it, and post the outcome of the page to the forum (that is, if he connection string doesn't contain private information):
Code:
....
mySQL= "INSERT INTO ResearchInfo "
mySQL= mySQL & "(Name,Site,ReqEmail,VPEmail) "
mySQL= mySQL & "VALUES ('" & Replace(Request.Form ("Contact_FullName"), "'","''") & "'"
mySQL= mySQL & ",'" & Replace(Request.Form("Site"), "'", "''") & "'"
mySQL= mySQL & ",'" & Replace(Request.Form("ReqEmail"), "'","''") & "'"
mySQL= mySQL & ",'" & Replace(Request.Form("VPEmail"), "'", "''") & "'" & "')"

Response.Write("Connection is " & myConnString & "<br />")
Response.Write("SQL is " & mySQL & "<br />")
Response.End
...
Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old March 17th, 2004, 11:59 AM
Authorized User
 
Join Date: Mar 2004
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to stellabantug
Default

This is the error message I get;

Microsoft VBScript compilation error '800a03ee'

Expected ')'

/OnlineForm/Email1.asp, line 120

Response.Write("Connection is " &amp; myConnString &amp; "&lt;br /&gt;")
------------------------------------^


What say you?

 
Old March 17th, 2004, 12:12 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

I say something went wrong with Copy and Paste.

Apparently you have an HTML aware editor, that replaces & with &amp; all by itself without telling you ;)

The code should look like this:

Response.Write("Connection is " & myConnString & "<br />")
Response.Write("SQL is " & mySQL & "<br />")
Response.End

With just a single ampersand between is " and myConnString. Since it's ASP there is no need to escape it as HTML

Imar'

---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old March 17th, 2004, 12:34 PM
Authorized User
 
Join Date: Mar 2004
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to stellabantug
Default

Gotcha!

But now its giving me the same error message as before:

Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

/OnlineForm/Email1.asp, line 71




 
Old March 17th, 2004, 01:08 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Arrange your code as follows. What's important is that the value for the connectionstring and the SQL statement are written to the screen:
Code:
Dim myConnString
Dim myConnection
Dim mySQL

myConnString = Application("SampDatabConn_ConnectionString")
' Set myConnection = Server.CreateObject("ADODB.Connection")
' myConnection.Open myConnString

mySQL= "INSERT INTO ResearchInfo "
mySQL= mySQL & "(Name,Site,ReqEmail,VPEmail) "
mySQL= mySQL & "VALUES ('" & Replace(Request.Form ("Contact_FullName"), "'","''") & "'"
mySQL= mySQL & ",'" & Replace(Request.Form("Site"), "'", "''") & "'"
mySQL= mySQL & ",'" & Replace(Request.Form("ReqEmail"), "'","''") & "'"
mySQL= mySQL & ",'" & Replace(Request.Form("VPEmail"), "'", "''") & "'" & "')"

Response.Write("Connection is " & myConnString & "<br />")
Response.Write("SQL is " & mySQL & "<br />")
Response.End

...
This shouldn't result in an error and instead you'll see the connection string and the SQL statement.

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
CDONTS and CDOSYS hamproof Classic ASP Databases 0 August 24th, 2007 01:37 PM
CDONTS to CDOSYS icis Classic ASP Basics 1 March 2nd, 2006 06:27 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.