Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old November 14th, 2003, 11:52 AM
peachsoda03 peachsoda03 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 10 peachsoda03 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Loop statement help

Hello,

I am having trouble creating a loop statement for an email I am trying to generate after the database is updated. I would like the email to list each item for a particular form. Right now it is only listing the first item of each form when the email is sent. Any ideas? Here is the email code:

if (debug = True) then
body = vbNewLine & "NOTE: THIS SYSTEM IS CURRENTLY IN DEBUG MODE AND ANY REPORTS YOU RECEIVE MAY BE FALSE" & vbNewLine & vbNewLine
end if

body = body & "---------------------" & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & "------" & vbNewLine & vbNewLine
body = body & "EACR Form Submission:" & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & "Items:" & vbNewLine & vbNewLine
body = body & "---------------------" & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & "------" & vbNewLine & vbNewLine & vbNewLine

esql = "SELECT * FROM Eacr WHERE ID = " & Request.Form("eacrID")
rs6.open esql, conn, adOpenstatic, adLockReadOnly, adCmdText

asql = "SELECT * FROM User WHERE ID = " & Rs6("UserID")
rs.open asql, conn, adOpenstatic, adLockReadOnly, adCmdText

body = body & "Submitted By: " & Rs("FirstName") & " " & Rs("LastName") & vbTab & vbTab & vbTab & vbTab & "Lot #: " & eacrID & vbNewLine
body = body & "Date Submitted: " & today & vbTab & vbTab & vbTab & vbTab & vbTab & "Item " & i & ":" & vbNewLine & vbNewLine

asql = "SELECT * FROM ItemDetails WHERE EACRID = " & Request.Form("eacrID")
rs.open asql, conn, adOpenstatic, adLockReadOnly, adCmdText

bsql = "SELECT Description FROM Disposition WHERE ID = " & Rs6("DispositionID")
rs2.open bsql, conn, adOpenstatic, adLockReadOnly, adCmdText

body = body & "Lot #: " & eacrID & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & " Serial: " & Rs("SerialNumber") & vbNewLine
body = body & "Disposition Type: " & Rs2(0) & vbTab & vbTab & vbTab & " Decal #: " & Rs("Decal") & vbNewLine

bsql = "SELECT * FROM Department WHERE ID = " & Rs6("DepartmentID")
rs2.open bsql, conn, adOpenDynamic, adLockReadOnly, adCmdText

csql = "SELECT * FROM Reason"
rs3.open csql, conn, adOpenstatic, adLockReadOnly, adCmdText

dsql = "SELECT * FROM Condition"
rs4.open dsql, conn, adOpenstatic, adLockReadOnly, adCmdText

body = body & "Requisition Number: " & Rs6("ReqNumber") & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & " Description: " & Rs("Description") & vbNewLine
body = body & "Recipient: " & Rs6("Recipient") & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & " Manufacturer: " & Rs("Manufacturer") & vbNewLine
body = body & "Erase Hard Drives: " & Rs6("HDDCheck") & vbTab & vbTab & vbTab & vbTab & vbTab & " Model: " & Rs("Model") & vbNewLine
body = body & "Department Name: " & Rs2("Name") & vbTab & vbTab & vbTab & vbTab & " Building: " & Rs("Building") & vbNewLine
body = body & "Department Number: " & Rs2("Number") & vbTab & vbTab & vbTab & vbTab & vbTab & " Room: " & Rs("Room") & vbNewLine

body = body & "Department Phone: " & Rs2("Telephone") & vbTab & vbTab & vbTab & vbTab & vbTab & " Reason Code: " & Rs3("Description") & vbNewLine
body = body & " " & vbTab & vbTab & vbTab & vbTab & vbTab & " Condition Code: " & Rs4("Description") & vbNewLine
body = body & " " & vbTab & vbTab & vbTab & vbTab & vbTab & " Funding: " & Rs("Funding") & vbNewLine
body = body & " " & vbTab & vbTab & vbTab & vbTab & vbTab & " Value: " & Rs("Value") & vbNewLine & vbNewLine

Rs4.close
Rs3.close
Rs2.close
Rs.close
Rs6.close

Last edited by peachsoda03 : November 14th, 2003 at 12:12 PM.

Reply With Quote
  #2  
Old November 15th, 2003, 05:45 AM
Monkey's Avatar
Monkey Monkey is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Germany (currently)
Posts: 83 Monkey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
I have experienced similar problems with email in the past, the only positive solution I have come up with is to set your variables from the database before writing the values directly to your email code.

So an example would be.
Code:
Dim tmpReqNum as Integer

tmpReqNum = Rs6("ReqNumber")

body = body & "Requisition Number: " & tmpReqNum & ......


Allthough saying that I have also had issues like this because I kept overwriting my body with the new version, so to get around that I created a new body variable which would build the entire body.

Example below is not directly relevant to you because the email body resides in Html within a database then it gets called and it checks for predefined areas of the email which contain a specific string to point out to the code that a correspionding item needs to be replaced there.

Code:
					If Not IsNull(fldPrefix) Then
						NewobjMailContent = replace(objMailContent, "[prefix]", NewPrefix)
					End If
					If Not IsNull(fldLname) Then
						NewobjMailContent = replace(NewobjMailContent, "[fname]", NewLname)
					End If


I hope this helps you in some way.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Loop statement help


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump





 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek