Go Back   CodingForums.com > :: Server side development > ASP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-20-2012, 05:29 PM   PM User | #1
keithboesker
New Coder

 
Join Date: Dec 2011
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
keithboesker is an unknown quantity at this point
Select Statement Array Trouble

I have a newsletter program I'm trying to use a group list like 1,2,3,4 in my database to send email to one or more groups. So I get the groups say 1,2 but when I try to get the email address from a user say in group 1 I get nothing. I believe it not finding the 1 in the list of 1,2,3 if the user is in those groups. Here's what I have:

Code:
NMGroups = Replace(UploadFormRequest("txtGroup"), " ", "") 'remove white space


strSQL = "SELECT * FROM NewsletterMembers WHERE NMActive = 'True' AND NMGroups IN ('" & NMGroups & "')"
Set sendemails = database.Execute(strSQL)
Thanks for your help in advance!!!!
keithboesker is offline   Reply With Quote
Old 10-21-2012, 02:46 AM   PM User | #2
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,210
Thanks: 59
Thanked 3,996 Times in 3,965 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
I *TOLD* you that using a delimited list in a single field WILL NOT WORK.

If this line of code:
Code:
NMGroups = Replace(UploadFormRequest("txtGroup"), " ", "")
results in the variable NMGroups having the value of "1,2,3,4" then the *ONLY* records that will match in your query are those where the field in the database is *EXACTLY* 1,2,3,4 !!!

It WILL NOT MATCH "1,2,3". It WILL NOT MATCH "1,2,3,4,5". It WILL NOT MATCH "1".

One more time: Your lack of understanding of correct database design has led you into a corner. You can't get out of this one.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 02:44 PM.


Advertisement
Log in to turn off these ads.