Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing data using ASP, problem

Status
Not open for further replies.

perryair

IS-IT--Management
Apr 7, 2005
91
0
0
IL
Hi Guys,
I'm trying to send particular data to another page and I can not understand where the problem is.
The data that I can send is "ItemID", If I trying to get other column name (Desc) from the database I receive nothing.

Thanks..

JS code:
function tellafriend()
{
window.open('tellafriend.asp?URL=http://prodsite/prod.asp?ItemID=<%=
Request.QueryString("ItemID")%>&Desc=<%=Request.QueryString("Desc")%>',
'sendbyemail','width=400,height=300,menubar=no,status=no,location=no,
toolbar=no,scrollbars=no,screenX=200,screenY=200,left=300,top=200');
}


ASP1:
<%

Const NumPerPage = 1
Dim ItemID
If Request.QueryString("ItemID") = "" then
ItemID = 1
Else
ItemID = Request.QueryString("ItemID")
End If

Dim conn
Set conn = Server.CreateObject("ADODB.Connection")
conn.ConnectionString= "DRIVER={SQL Server};SERVER=sql;DATABASE=db;UID=user;PWD=pass"
conn.Open

Dim rs
Set rs = Server.CreateObject("ADODB.Recordset")

rs.CursorLocation = adUseClient

rs.CacheSize = NumPerPage

Dim strSQL
strSQL = "SELECT * FROM products"
rs.Open strSQL, Conn

rs.MoveFirst
rs.PageSize = NumPerPage

Dim TotalPages
TotalPages = rs.PageCount

rs.AbsolutePage = ItemID

Dim count

Count = 0
Do While Not rs.EOF And Count < rs.PageSize
%>



ASP2:

<%
Desc = Request.QueryString("Desc")
URL = Request.QueryString("URL")
If Len(URL) = 0 Then URL = " ' The default URL

If Len(Request.Form("SendersEmail")) > 0 Then
Dim objMail,FriendEmail,I
sBody = "The Page at " & URL & Desc & " has been recommend by " & Request.Form("SendersEmail") & vbCrLf & " -- Message -- " & vbcrlf & Request.Form("Message")
I=0

Set objMail = Server.CreateObject("SMTPsvg.Mailer")
objMail.RemoteHost = "localhost"
objMail.FromAddress = "webmaster@prodsite.com"
objMail.FromName = "Sender"
objMail.Subject = "Recommended link"
objMail.BodyText = sBody
objMail.Priority = 1

Do While True
FriendEmail = Request.Form("FriendEmail" & I)
If Len(FriendEmail) = 0 Then
Exit Do
Else
objMail.AddRecipient "form filler",FriendEmail
End If
I=I+1
Loop
On Error Resume Next
objMail.SendMail
Set objMail = Nothing
Response.write "<H1>Thank you for spreading the word</H1>"
Response.write "<a href=""" & URL & """>Click here to return to " & URL & "</a>"
Else
%>
<form method="POST" action="tellafriend.asp?URL=<%= URL %>&Desc=<%= Desc %>" style="text-align: right">
<p dir="rtl">Link:</p>
<p dir="rtl"><span lang="en-us">eMail </span>Sender: <input type="text" name="SendersEmail" size="25"></p>
<p dir="rtl"><b>Tell a friend:</b></p>
<p dir="rtl">
1. <input type="text" name="FriendEmail0" size="29"><br>
2. <input type="text" name="FriendEmail1" size="29"><br>
3. <input type="text" name="FriendEmail2" size="29"><br>
4. <input type="text" name="FriendEmail3" size="29"><br>
5. <input type="text" name="FriendEmail4" size="29"><br>
</p>
<p dir="rtl"><b>Remarks:</b></p>
<p dir="rtl"><textarea rows="6" name="Message" cols="41"></textarea></p>
<p dir="rtl"><input type="submit" value="Send"></p>
</form>
<% End If%>
 
Perhaps the Desc field contains spaces or other characters that don't play nice with URLs ??? If so you need to "url encode" the field value.

Or is it possible just flat out too many characters? If the Desc is a description field with a couple of paragraphs this could also be a problem.

Why not just pass the ID to the other page and then look up the description in the database on the receiving end?
 
please do response.write statments at each and every stage..that way you can know if all the variables are holding proper values...

Desc is a keyword and i would not suggest you to use it as a field name...

-DNG
 
Good catch DNG! Desc is used for a decending sort in an SQL ORDER BY clause.
 
Thanks Sheco.. good catch.
as you can see this is a 'tell a friend' page and I already pass the ItemID to ASP2 but I would like to send this by email, I don't want display the query results on the screen.

Any suggestion?
 
so are you having problem with sending email or are you having problem in passing variables...

-DNG
 
PLEASE HELP.... I am stuck, yes.. I would need to send it by email.
 
What is this semi colon doing here?

function tellafriend()
{
window.open('tellafriend.asp?URL=http://prodsite/prod.asp?ItemID=<<b>;</b>%=
Request.QueryString("ItemID")%>&Desc=<%=Request.QueryString("Desc")%>',
'sendbyemail','width=400,height=300,menubar=no,status=no,location=no,
toolbar=no,scrollbars=no,screenX=200,screenY=200,left=300,top=200');
}
 
I'm trying to bold that semicolon.

Code:
What is this semi colon doing here?

function tellafriend() 
{ 
window.open('tellafriend.asp?URL=http://prodsite/prod.asp?ItemID=<[b];[/b]%=
Request.QueryString("ItemID")%>&Desc=<%=Request.QueryString("Desc")%>',
'sendbyemail','width=400,height=300,menubar=no,status=no,location=no,
toolbar=no,scrollbars=no,screenX=200,screenY=200,left=300,top=200'); 
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top