473,405 Members | 2,338 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Problem using Select Case statement

14
I am currently in the process of setting up an asp page that sends an inquiring student an email regarding his/her application status. The student enters his/her email address on a web page, the address is associated with the correspponding record in a sql database table, and an email is generated and sent to them based on app status. I am focusing on the "Incomplete" portion which will list all null fields from the table in the email. Using the code below works fine, although as soon as I insert a Select Case statement to determine what type of email should be sent, my null fields disappear from the email. An email is still sent, but without the list of null fields. Any ideas? Thanks.

Currently my asp script is sending email just fine along with the correct null fields from my database. The only problem I am having is using 'select case' statements. I have one field in this table that distinguishes if an application is complete. There are three options, (Complete, Incomplete, Under Review). I would like the script to check these values and send the appropriate email. The null field email would go with the Incomplete application email. The other two just would send out a general email letting them know their status. Any time I setup a select case statement around the code, the emails cease to show the null fields anymore. Any ideas? Here is my latest code:

<%
Dim Applicant
Set Applicant = Request.Form("txtEmailAddress")
Dim oRs, oField, fieldCount, FName, Status
Set oRs = Server.CreateObject("ADODB.Recordset")
oRs.Open "vwAcademicsData WHERE Email = '" & Applicant & "';","DSN=OSC"
Set FName = oRs("First_Name")
Set Status = oRs("ApplicationStatus")


sMsg = sMsg & "Greetings " & FName & "!" & vbCRLF & vbCRLF
sMsg = sMsg & "Your application to the College has been received." & vbCRLF & vbCRLF
sMsg = sMsg & "Any missing items on your application are listed below:" & vbCRLF & vbCRLF
For Each oField In oRs.Fields
If IsNull( oRs( oField.name ) ) Then
sMsg = sMsg & oField.name & VbCrLf
End If
Next

Dim Mail
Set Mail = CreateObject("CDONTS.NewMail")
Mail.From = "user@college.edu"
Mail.To = Applicant
Mail.Bcc = "helpdesk@college.edu"
Mail.Subject = "Your Admission Status"
Mail.Body = sMsg
Mail.Send

oRs.Close
Set oRs = Nothing
%>
Feb 21 '08 #1
3 1913
jeffstl
432 Expert 256MB
It would probably help if I could see where and how exactly you are using the Select Case?

Once idea however would be to create a flag to see if a field was marked as null, then check this flag to determine if the incomplete email goes out.

This might not be what your looking for, but like I said, if I could see how and where the select case is going that is causing issues I might be able to see the problem.

Expand|Select|Wrap|Line Numbers
  1. dim strNullFlag as String
  2. strNullFlag = "N"
  3.  
  4. For Each oField In oRs.Fields
  5.      If IsNull( oRs( oField.name ) ) Then
  6.           sMsg = sMsg & oField.name & VbCrLf
  7.           strNullFlag = "Y"
  8.      End If
  9. Next
  10.  
  11.  
Feb 21 '08 #2
bpw22az
14
The email seems to work, although when using the case statement to determine the status it will not place the null fields in the email. The email goes out just fine for all, but is missing the null fields when I add the Select Case code.

<%
Dim Applicant
Set Applicant = Request.Form("txtEmailAddress")
Dim oRs, oField, fieldCount, FName, Status
Set oRs = Server.CreateObject("ADODB.Recordset")
oRs.Open "vwAcademicsAdmissionsData WHERE Email = '" & Applicant & "';","DSN=OSC"
Set FName = oRs("First_Name")
Set Status = oRs("ApplicationStatus")

Select Case Status
case "AI"
sMsg = sMsg & "Greetings " & FName & "!" & vbCRLF & vbCRLF
sMsg = sMsg & "Your application to the College has been received." & vbCRLF & vbCRLF
sMsg = sMsg & "Any missing items on your application are listed below:" & vbCRLF & vbCRLF
For Each oField In oRs.Fields
If IsNull( oRs( oField.name ) ) Then
sMsg = sMsg & oField.name & VbCrLf
End If
Next
End Select
Dim Mail
Set Mail = CreateObject("CDONTS.NewMail")
Mail.From = "user1@college.edu"
Mail.To = Applicant
Mail.Bcc = "user@college.edu"
Mail.Subject = "Your Admission Status"
Mail.Body = sMsg
Mail.Send

oRs.Close
Set oRs = Nothing
%>
Feb 21 '08 #3
jeffstl
432 Expert 256MB
Well at first glance I don't see what would cause that. Especially if your msg is getting populated.

The only thing that adding the select case as it appears here would cause would be for the code under the Case "AI" to not be run.

I guess I would make certain that the code under the Case "AI" is actually executing.

You can check by trying to either step through the code (not sure what set up you have), or you can try a response.write or debug.print on the Status to see what actually ends up in that variable.

Put a response.write Status right before the Select Case and see what is in "Status" before you hit your Select Case. From there maybe you can write out the values as the code executes to figure out whats going wrong.
Feb 22 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

17
by: Newbie | last post by:
Dear friends, I am having a hard time understanding how to use a SELECT CASE in ASP. I have used it in VB but never in ASP scripting. Scenerio: I have 2 textboxes on a form that I have to...
10
by: JMorrell | last post by:
First post to this community so am not sure if this is the correct place. Here goes. I have a MS Access db that keeps track of employees sick and annual leave balances. In it, I have a report,...
5
by: Ritesh | last post by:
Hi All, According to my observation using SP_WHO2 in my database, some INSERT statements are getting blocked by SELECT statements. Though the blocking SELECT statement is having ReadPast hint,...
1
by: Alex.Wisnoski | last post by:
I have a data entry form with a combo box to look up an entrant's name. If the name is already in the table then it pulls up the record and that part of the form works fine. If the name isn't in...
8
by: | last post by:
Hello, This is gonna sound real daft, but how do I test a Select Case statement for variants of a theme? Here's a snippet of my code... Select Case sUsr Case "Guest", "TsInternetUser",...
8
by: Jeff Gilbert | last post by:
Hello all. I'd appreciate some help with this one: First the DDL: CREATE TABLE ( NOT NULL , NULL , NOT NULL , (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL , NOT NULL...
22
by: b_r | last post by:
Hi, I'm trying to make a simple operation (insert into DB) in VB 2005 and SQL Server. The code is as follows: Dim sConnectionString As String = _ "Data...
2
osward
by: osward | last post by:
Hello there, I am using phpnuke 8.0 to build my website, knowing little on php programing. I am assembling a module for my member which is basically cut and paste existing code section of...
10
by: amitabh.mehra | last post by:
Hi I havent used MQT before. Read the online tips and tutorials but none seems to give any hint for my problem. I have a base table (base_table) as: st varchar(25) default...
6
by: =?Utf-8?B?amVmZmVyeQ==?= | last post by:
i need help with a combo box and this same code works on my first tab with a combo box. The error or problem i have is this code causes an index out of range error when i run it on my second combo...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.