Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Mailing App Duplicate problem...

Reply
Thread Tools

Mailing App Duplicate problem...

 
 
@sh
Guest
Posts: n/a
 
      07-06-2006
Guys,

I've written an email sending script to mass send to our database - some of
our subscribers are subscribed to multiple list, and so when selecting the
entire database, I want to ensure I don't have Duplicates.

To avoid this, I am selecting the recordset of all users, ordering by Email
address, sending the email, moving onto the next record and then starting a
loop to keep looping until the email address is different, but it doesn't
work... see example below...

-----------------------------------

Do While NOT RS_RecipientsForCampaign.EOF

SEND THE EMAIL HERE...

RS_RecipientsForCampaign.MoveNext

If NOT RS_RecipientsForCampaign.EOF Then
** Do While TheUsersEmailAddress =
RS_RecipientsForCampaign("Email") AND NOT RS_RecipientsForCampaign.EOF
RS_RecipientsForCampaign.MoveNext
Loop
End If

Loop

-----------------------------------

When running, the script works fine, BUT I get an Unspecified error (I HATE
that message) at the end of the script, pointing me to the line number
marked with ** above.

How can I cure this? I've tried everything but need a solution to amend this
section of code that works!!

Cheers, Ash


 
Reply With Quote
 
 
 
 
@sh
Guest
Posts: n/a
 
      07-06-2006
Actually, sorry just to confirm, here is the exact error message...

error '80020009'
Exception occurred.
blah.asp, line 799



"@sh" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Guys,
>
> I've written an email sending script to mass send to our database - some
> of our subscribers are subscribed to multiple list, and so when selecting
> the entire database, I want to ensure I don't have Duplicates.
>
> To avoid this, I am selecting the recordset of all users, ordering by
> Email address, sending the email, moving onto the next record and then
> starting a loop to keep looping until the email address is different, but
> it doesn't work... see example below...
>
> -----------------------------------
>
> Do While NOT RS_RecipientsForCampaign.EOF
>
> SEND THE EMAIL HERE...
>
> RS_RecipientsForCampaign.MoveNext
>
> If NOT RS_RecipientsForCampaign.EOF Then
> ** Do While TheUsersEmailAddress =
> RS_RecipientsForCampaign("Email") AND NOT RS_RecipientsForCampaign.EOF
> RS_RecipientsForCampaign.MoveNext
> Loop
> End If
>
> Loop
>
> -----------------------------------
>
> When running, the script works fine, BUT I get an Unspecified error (I
> HATE that message) at the end of the script, pointing me to the line
> number marked with ** above.
>
> How can I cure this? I've tried everything but need a solution to amend
> this section of code that works!!
>
> Cheers, Ash
>



 
Reply With Quote
 
 
 
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      07-06-2006
@sh wrote:
> Guys,
>
> I've written an email sending script to mass send to our database -
> some of our subscribers are subscribed to multiple list, and so when
> selecting the entire database, I want to ensure I don't have
> Duplicates.
>
> To avoid this, I am selecting the recordset of all users, ordering by
> Email address, sending the email, moving onto the next record and
> then starting a loop to keep looping until the email address is
> different, but it doesn't work... see example below...
>
> -----------------------------------
>
> Do While NOT RS_RecipientsForCampaign.EOF
>
> SEND THE EMAIL HERE...
>
> RS_RecipientsForCampaign.MoveNext
>
> If NOT RS_RecipientsForCampaign.EOF Then
> ** Do While TheUsersEmailAddress =
> RS_RecipientsForCampaign("Email") AND NOT RS_RecipientsForCampaign.EOF
> RS_RecipientsForCampaign.MoveNext
> Loop
> End If
>
> Loop
>
> -----------------------------------
>
> When running, the script works fine, BUT I get an Unspecified error
> (I HATE that message) at the end of the script, pointing me to the
> line number marked with ** above.
>
> How can I cure this? I've tried everything but need a solution to
> amend this section of code that works!!
>

You should be able to construct a query that returns unique addresses.
However, the details for how that would be done depend on the database
type and version you are using (please always supply this information
when requesting database-related help. It is almost always relevant)

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


 
Reply With Quote
 
@sh
Guest
Posts: n/a
 
      07-06-2006
> You should be able to construct a query that returns unique addresses.
> However, the details for how that would be done depend on the database
> type and version you are using (please always supply this information
> when requesting database-related help. It is almost always relevant)


Thanks for your reply. We're using SQLServer v7, I did consider how to
return unique addresses, perhaps by using Distinct, but we also need
alongside that the other details for the user, for example title, firstname,
lastname etc.

Surely there is a simple solution to get this script working? What am I
missing?


 
Reply With Quote
 
@sh
Guest
Posts: n/a
 
      07-06-2006
Just solved it myself, for anyone else with the same problem, you need to
look into the 'Exit Do' function, VERY DAMN HANDY!!!!

Final code bit now looks like this...

Do While NOT RS_RecipientsForCampaign.EOF
If (TheUsersEmailAddress <>
RS_RecipientsForCampaign("Email")) Then
Exit Do
Else
RS_RecipientsForCampaign.MoveNext
End If
Loop

Cheers, @sh


"@sh" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>> You should be able to construct a query that returns unique addresses.
>> However, the details for how that would be done depend on the database
>> type and version you are using (please always supply this information
>> when requesting database-related help. It is almost always relevant)

>
> Thanks for your reply. We're using SQLServer v7, I did consider how to
> return unique addresses, perhaps by using Distinct, but we also need
> alongside that the other details for the user, for example title,
> firstname, lastname etc.
>
> Surely there is a simple solution to get this script working? What am I
> missing?
>



 
Reply With Quote
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      07-06-2006
@sh wrote:
>> You should be able to construct a query that returns unique
>> addresses. However, the details for how that would be done depend on
>> the database type and version you are using (please always supply
>> this information when requesting database-related help. It is almost
>> always relevant)

>
> Thanks for your reply. We're using SQLServer v7, I did consider how to
> return unique addresses, perhaps by using Distinct, but we also need
> alongside that the other details for the user, for example title,
> firstname, lastname etc.


Then use GROUP BY

Of course, now I need to know something about your table's structure.
However, something like:

SELECT email, Max(title) title, Max(firstname) firstname,
Max(lastname) lastname
from table
group by email

>
> Surely there is a simple solution to get this script working?

Probably, but I wouldn't bother with this inefficient technique.
Concentrate on retrieving the correct data from your database. Never
retrieve more data than you are going to use.

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


 
Reply With Quote
 
@sh
Guest
Posts: n/a
 
      07-06-2006
Thanks for your help Bob, will look at reworking the SQL later on, got to
just get the thing working for now ;o)

Cheers, @sh


 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
the easiest way to convert a .net windows app to web app? tom ASP .Net 4 10-24-2008 05:57 PM
mailing list web-app Nathan Coast Java 0 11-02-2004 11:04 AM
win app and web app mimi ASP .Net 1 07-29-2004 03:19 AM
Asp.net app, Unable to load dll!!, while same dll loads properly in Win form app NGM ASP .Net 0 11-06-2003 10:34 AM
preventing duplicate row insertion from asp.net app aboesteanu@yahoo.com ASP .Net 2 08-11-2003 07:56 PM



Advertisments