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 September 18th, 2004, 11:35 AM
Authorized User
 
Join Date: Apr 2004
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
Default CDO type mismatch error

I get a type mismatch error thrown using CDO.Message on the following line:

.To = rsUpdate("Email")

the .To field is populated with the email address that is returned in the resultset?

Type mismatch errors normally indicate mismatched data types? I'm not sure what is wrong here?

I can provide more code if necessary.

Any help is appreciated. Thanks.
-Dman100-


 
Old September 18th, 2004, 08:30 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi,

Can you confirm, the value that comes along with the resultset is a valid one?

_________________________
- Vijay G
Strive for Perfection
 
Old September 19th, 2004, 12:29 AM
Authorized User
 
Join Date: Apr 2004
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Vijay,

Yes, the value is valid. To check for a valid value I used:
<%
Response.Write(rsUpdate("Email"))
%>

A valid email address is displayed based on the ID value passed in the querystring.

I'm using the Dreamweaver update recordset behavior to update a database record. When I submit the form to append the update, I want to use CDOSYS to send an email to the email address stored in that record.

rsUpdate("Email") holds the value for the email.

Now, I can get the email to send, but the problem is that everytime I click the link to update, it sends an email. Even if no change is made, it will send an email. All I do is just click the update link, then it takes me to the update page passing the ID via a querystring (no changes are made) and it sends an email. I can't figure out why?

I think it has to do with where I placed the CDOSYS code. Here is a snippet of the code:

<%
Dim rsUpdate__MMColParam
rsUpdate__MMColParam = "0"
If (Request.QueryString("LoginID") <> "") Then
  rsUpdate__MMColParam = Request.QueryString("LoginID")
End If
%>
<%
Dim rsUpdate
Dim rsUpdate_numRows

Set rsUpdate = Server.CreateObject("ADODB.Recordset")
rsUpdate.ActiveConnection = MM_DBConn_STRING
rsUpdate.Source = "SELECT * FROM dbo.tblLogin WHERE LoginID = " + Replace(rsUpdate__MMColParam, "'", "''") + ""
rsUpdate.CursorType = 0
rsUpdate.CursorLocation = 2
rsUpdate.LockType = 1
rsUpdate.Open()

rsUpdate_numRows = 0

sch = "http://schemas.microsoft.com/cdo/configuration/"
mailbody = "Thank you for joining my weblog. Your registration has been approved."

Set cdoConfig = CreateObject("CDO.Configuration")

With cdoConfig.Fields
.Item(sch & "sendusing") = 2 ' cdoSendUsingPort
.Item(sch & "smtpserver") = "mail.hou.wt.net"
.update
End With

Set cdoMessage = CreateObject("CDO.Message")

With cdoMessage
Set .Configuration = cdoConfig
.From = "[email protected]"
.To = rsUpdate("Email")
.Subject = "Dwayne-Epps-Weblog-Confirmation"
.HTMLBody = mailbody
.Send
End With

Set cdoMessage = Nothing
Set cdoConfig = Nothing
%>

I tried moving the CDOSYS code within the code that generates the recordset update. Specifically, within the following code:

' execute the update
    Set MM_editCmd = Server.CreateObject("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_editConnection
    MM_editCmd.CommandText = MM_editQuery
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close

sch = http://schemas.microsoft.com/cdo/configuration/
mailbody = "Thank you for joining my weblog. Your registration has been approved."

Set cdoConfig = CreateObject("CDO.Configuration")

With cdoConfig.Fields
.Item(sch & "sendusing") = 2 ' cdoSendUsingPort
.Item(sch & "smtpserver") = "mail.hou.wt.net"
.update
End With

Set cdoMessage = CreateObject("CDO.Message")

With cdoMessage
Set .Configuration = cdoConfig
.From = "[email protected]"
.To = rsUpdate("Email")
.Subject = "Dwayne-Epps-Weblog-Confirmation"
.HTMLBody = mailbody
.Send
End With

Set cdoMessage = Nothing
Set cdoConfig = Nothing

    If (MM_editRedirectUrl <> "") Then
      Response.Redirect(MM_editRedirectUrl)
    End If
  End If
End If

However, when I move the code here it generates the type mismatch error.

I hope this makes sense? I can post the code for the entire page, if that is helpful.

Thanks for any help!
-Dman100-

 
Old September 19th, 2004, 01:46 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi DMan,

Yes, it would be better if you could post the entire code, if that is not too long.

_________________________
- Vijay G
Strive for Perfection
 
Old September 19th, 2004, 01:54 AM
Authorized User
 
Join Date: Apr 2004
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Vijay,

Yes, I zipped up the file, so you can download and view all the code in the page.

Here is the link:

www.dwayneepps.com/test.asp

Thanks for helping with this!
-Dman100-

 
Old September 19th, 2004, 02:21 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

You should move the CDO related code into UPDATE region, so that it gets executed only when the UPDATE happens, but you cannot use the following in there.
Code:
.To=rsUpdate("Email")
Because,
Code:
Dim rsUpdate
comes in the later stage of the code, and rsUpdate would have nothing populated in it, as the page is submitted on UPDATE click and RECORDSET is not initialized with rows, when you use that within update region on submit.

So you should pick the email value from within the code where you construct the UDATE statement next to
' *** Update Record: construct a sql update statement and execute it
...
...
And use that to be assigned there
Code:
.To=Use_that_EMail_here
Now, I got a question, are you letting the user to modify the EMAIL value too on the form? If so, to which Id will you be mailing these data? OLD one(rsUpdate("Email")) or to the NEW one(the one after Edit)?

Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old September 19th, 2004, 02:58 AM
Authorized User
 
Join Date: Apr 2004
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Vijay,

Okay, I understand. I'm trying to figure out how I can set the email value within the update section.

The user doesn't update the information. The only field that is updated is the access level field, which is updated by the administrator. So, when the administrator grants access, an email will be sent to the user letting them know their access level. No other fields are modified.

So, I only pass the UserID via a querystring into the update.asp page.

I'm not sure how I can obtain the email value without using rsUpdate("Email")? Any suggestions?

Thanks again for all your help. I really do appreciate it.
-Dman100-



 
Old September 19th, 2004, 03:34 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Probably you can have a hidden field in the form, and request that on submit and use that to send out mails.

Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old September 20th, 2004, 01:58 PM
Authorized User
 
Join Date: Apr 2004
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Vijay,

Added the hidden form field as you suggested. No more errors and it works great! Thanks a bunch for your help!
-Dman100-






Similar Threads
Thread Thread Starter Forum Replies Last Post
Error-0x800A000D-Type mismatch kishy449 Classic ASP Basics 0 July 23rd, 2007 04:48 AM
Type Mismatch error Sheraz Khan Classic ASP Basics 0 May 16th, 2007 08:12 AM
CreateObject Type mismatch error Deepmala Classic ASP Professional 1 February 7th, 2006 04:28 AM
Data Type mismatch error clueless_may Access VBA 1 May 5th, 2004 09:16 AM
Data Type Mismatch error transcona Classic ASP Databases 4 June 25th, 2003 07:23 PM





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