Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: e-mail database query results


Message #1 by "P Brady" <wpprod@e...> on Wed, 24 Jul 2002 17:38:26
I wish to email (CDONTS) the Username of the script below the results of 
the database query.  How do you write the strings for the results to show 
up as formatted text in the e-mail body?

Brady Pick



<%@ Language=VBScript %>
<html>
<body>
<%
	Dim DBName, objConn, objRS, strSQL
	Dim NewID, NewUsername, Newa, NewB

	NewID = Request.Form("ID")
	NewUsername = Session("Username")
	Newa = Request.Form("a")
	NewB = Request.Form("B")
	Username = Session("Username")

	DBName = server.mappath("..\data\2000.mdb") 
	Set objConn = Server.CreateObject("ADODB.Connection")
	objConn.ConnectionString = "DBQ=" & DBName & ";Driver={Microsoft 
Access Driver (*.mdb)};"
	objConn.Open

	Set objRS = Server.CreateObject("ADODB.Recordset")

	strSQL = "SELECT * FROM InfoRequest Where [Username] = '"& 
NewUsername &"'"
	Set objRS= objConn.execute(strSQL)
	
	'//Clear memory

	'Build table header
	With Response
		.write "<table border=1 cellpadding=5 cellspacing=0>"
		.write "<tr bgcolor=goldenrod>"
		.write "<td>X to delete</td>"
		.write "<td>###</td>"
		.write "<td>Username</td>"
		.write "<td>a</td>"
		.write "<td>B</td>"
		.write "</tr>"
end with

Do While Not objRS.eof
%>

<tr>
<td>
<form action="email-request.asp" method="Post">


<TD><% = objRS("ID")%></TD>
<TD><% = objRS("Username")%></TD>
<TD><% = objRS("a")%></TD>
<TD><% = objRS("B")%></TD>
</TR>
<%
objRS.movenext
Loop
%>
</table>
<%	objConn.close
	Set ObjRS = Nothing

%>
<input type="submit" value="email-results">
<input type="hidden" name="Username" value="<%=Session("Username") %>">

</form>  &nbsp;<p>


</table>

</p>

</body>
</html>

  Return to Index