473,811 Members | 3,299 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem using Select Case statement

14 New Member
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("t xtEmailAddress" )
Dim oRs, oField, fieldCount, FName, Status
Set oRs = Server.CreateOb ject("ADODB.Rec ordset")
oRs.Open "vwAcademicsDat a WHERE Email = '" & Applicant & "';","DSN=O SC"
Set FName = oRs("First_Name ")
Set Status = oRs("Applicatio nStatus")


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("C DONTS.NewMail")
Mail.From = "user@college.e du"
Mail.To = Applicant
Mail.Bcc = "helpdesk@colle ge.edu"
Mail.Subject = "Your Admission Status"
Mail.Body = sMsg
Mail.Send

oRs.Close
Set oRs = Nothing
%>
Feb 21 '08 #1
3 1934
jeffstl
432 Recognized Expert Contributor
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 New Member
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("t xtEmailAddress" )
Dim oRs, oField, fieldCount, FName, Status
Set oRs = Server.CreateOb ject("ADODB.Rec ordset")
oRs.Open "vwAcademicsAdm issionsData WHERE Email = '" & Applicant & "';","DSN=O SC"
Set FName = oRs("First_Name ")
Set Status = oRs("Applicatio nStatus")

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("C DONTS.NewMail")
Mail.From = "user1@college. edu"
Mail.To = Applicant
Mail.Bcc = "user@college.e du"
Mail.Subject = "Your Admission Status"
Mail.Body = sMsg
Mail.Send

oRs.Close
Set oRs = Nothing
%>
Feb 21 '08 #3
jeffstl
432 Recognized Expert Contributor
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
14652
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 allow entry to one or the other or Both at the same time. Now I tried to use an If ElseIf but it got too hard to track, so now I am using a SELECT CASE Statement.
10
1930
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, built around a query, that lists everyone's leave balances. There are columns (fields) that are generated with nested IIF statements. Everything there works like it should and the results are accurate. Now, I'm wanting to put this SQL query...
5
5465
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, i think, it will only read past locked resources but will not guarantee the select statement itself not blocking other statements(in my case Insert). According to my knowledge
1
2679
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 the table then I want to be able to add it but this part is not working. I enter a name that is not in the table and press Enter. I step through the code and it appears to work until I get to "Exit Sub". At this point a warning message box...
8
4726
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", "krbtgt", "quality7" ' don't show
8
2482
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 CONSTRAINT DEFAULT
22
4333
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 Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\DB.mdf....
2
2887
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 various module that I found it useful. Here is the 1st problem I encounter: I had a function to edit a event row form the database which is fine with me, than I pass on the code to a function that save(update) the data to the database.
10
4410
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 'my_null' dt timestamp default '1900-01-01-00.00.00.00000'
6
1878
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 box: (errored code) Select Case ComboBox2.text Case Is ="Execute Program" 'code to execute program here Case Is ="Other Command that executes code at a certain time" ' code below the same as above except that it works But not my first(this...
0
9607
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10652
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10395
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10137
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7673
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6895
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5561
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4346
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3026
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.