Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #21 (permalink)  
Old June 9th, 2004, 01:52 PM
Friend of Wrox
 
Join Date: Aug 2003
Location: Halifax, Nova Scotia, Canada.
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It said

Exception occurred

but the email's were still sent to my test address so I am not sure why that is

-----------------------------------------------------------
"Don't follow someone who's not going anywhere" John Mason
Reply With Quote
  #22 (permalink)  
Old June 9th, 2004, 04:38 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Nothing else? No error number?

What happens when you write out the SQL statement? I assume your code looks different from what you posted last time??

update "ORNewsletterTest set Mailsent=1 where NewsletterId In (" & NewsletterId & ")"

This won't work, as this isn't valid string or sql statement. Try fixing it, like this for example:

Dim SQL
SQL = "UPDATE ORNewsletterTest SET Mailsent=1 WHERE NewsletterId IN (" & NewsletterId & ")"
Response.Write(SQL)
Response.End

If you put that code in, what do you get?

Imar

---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #23 (permalink)  
Old June 10th, 2004, 07:12 AM
Friend of Wrox
 
Join Date: Aug 2003
Location: Halifax, Nova Scotia, Canada.
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here is my new code with your new update statment

It stops on this line

error '80020009'
Exception occurred.

NewsletterId = NewsletterId & RS("NewsletterId")

-----------------------------------------------------------
"Don't follow someone who's not going anywhere" John Mason
Reply With Quote
  #24 (permalink)  
Old June 10th, 2004, 07:18 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

What I meant was for you to post the outcome of your SQL statement. I think it will end up like this:

WHERE Bla bla IN (1, 2, 3, )

As you can see, it ends with an additional comma, which is not allowed. You'll need to strip it off before you send it to the database.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #25 (permalink)  
Old June 10th, 2004, 07:21 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Oh, and another thing: You should move the code that adds the ID to inside the loop:

  RS.MoveNext
next
.....

     'And store the mailId or KeyFieldValue in an array

    If len(NewsletterId) > 0 Then
        NewsletterId = NewsletterId & ", "
    end if
    NewsletterId = NewsletterId & RS("NewsletterId")

As you can see, you loop through your entire recordset. After the last record, you try to access the recordset, which is not going to work as it is now EOF.

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #26 (permalink)  
Old June 10th, 2004, 07:35 AM
Friend of Wrox
 
Join Date: Aug 2003
Location: Halifax, Nova Scotia, Canada.
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I can't show you the outcome of the sql statment because it never makes it there I moved this up into the loop but it still generates an error
I don't think the syntax is right :-(


If len(NewsletterId) > 0 Then
    NewsletterId = NewsletterId & ", "
    end if
 NewsletterId = NewsletterId & RS("NewsletterId")



-----------------------------------------------------------
"Don't follow someone who's not going anywhere" John Mason
Reply With Quote
  #27 (permalink)  
Old June 10th, 2004, 07:45 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Did you move it to before the MoveNext call?
Reply With Quote
  #28 (permalink)  
Old June 10th, 2004, 07:55 AM
Friend of Wrox
 
Join Date: Aug 2003
Location: Halifax, Nova Scotia, Canada.
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
Default

well I did now ;)

Okay this time I got this

Update ORNewsletterTest set Mailsent=1 where NewsletterId in (, 1, 2, 3, 4, 5)



-----------------------------------------------------------
"Don't follow someone who's not going anywhere" John Mason
Reply With Quote
  #29 (permalink)  
Old June 10th, 2004, 08:59 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Right, that's what I thought. You need a way to ignore the first comma. There are at least 2 ways to do that.

1. Strip if of, right before you send it.

NewsletterId = Right(NewsletterId, (Len(NewsletterId) -2))

2. Alternatovely, don't add it in the first place. Inside your main loop, add a counter that keeps track of the number of records. If it's zero (the first record), don't add the comma:

If Len(NewsletterId) > 0 And LoopCounter > 0 Then
  NewsletterId = NewsletterId & ", "
End If


Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #30 (permalink)  
Old June 10th, 2004, 09:17 AM
Friend of Wrox
 
Join Date: Aug 2003
Location: Halifax, Nova Scotia, Canada.
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I added the loop like this

    If Len("NewsletterId") > 0 And LoopCounter > 0 Then
          NewsletterId = NewsletterId & ", "
    End If
    NewsletterId = NewsletterId & RS("NewsletterId")

But now it returns this vaule

Update ORNewsletterTest set Mailsent=1 where NewsletterId in (12345)

[EDIT]I used this instead

NewsletterId = Right(NewsletterId, (Len(NewsletterId) -2))

and it works great [EDIT]

-----------------------------------------------------------
"Don't follow someone who's not going anywhere" John Mason
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Newsletter Mechanism vivek_inos ASP.NET 1.0 and 1.1 Professional 1 September 22nd, 2007 07:38 AM
Where is the newsletter option luisjeronimo BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 3 July 20th, 2007 03:16 PM
newsletter vantoko BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 2 February 28th, 2007 03:28 AM
Newsletter sydneyausguy BOOK: Professional DotNetNuke ASP.NET Portals ISBN: 0-7645-9563-6 1 August 19th, 2005 05:23 PM
help with newsletter question AStuntz Beginning PHP 1 May 13th, 2004 06:54 PM



All times are GMT -4. The time now is 03:13 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.