This topic is locked

How to reference a field in a different table ?

6/24/2009 2:47:39 PM
ASPRunnerPro General questions
G
gsxrian author

I want to reference a field in a different table. how would i do this ?
Sample of code i want to change
rmail("to")=data("email")

rmail("subject")="Oracle DBA Requirement"

rmail("body")=dal.table("dbo.jobdesc.Description") This is the line i want to change
The table only has a description field and cannot use any index.

I want to add a one time job description for each email campaign.
All the code.
dim arr,i

if Request.Form("a")="email" then

if Request("selection[]").Count>0 then

body=""

set rmail=CreateDictionary()

for i=1 to Request.Form("selection[]").Count

arr=split(Request.Form("selection[]").Item(i),"&")

if asp_count(arr)>=0 then

set keys=CreateDictionary()

keys("ID")=asp_urldecode(arr(0))

where = KeyWhere(keys,"")

set data = dal.table("dbo.contact").Query(where,"")

'body=body & "ID: " & data("ID") & vbcrlf

'body=body & "firstname: " & data("firstname") & vbcrlf

'body=body & "lastname: " & data("lastname") & vbcrlf

'body=body & "email: " & data("email") & vbcrlf & "-------------------" & vbcrlf & vbcrlf

rmail("to")=data("email")

rmail("subject")="Oracle DBA Requirement"

'rmail("body")=dal.table("dbo.jobdesc.Description")

'rmail("body")=body

set arr = runner_mail(rmail)

data.close

Set data=nothing

end if

next

' send the email

'rmail("to")="ianfila2@gmail.com"

'rmail("subject")="Testing Email Select Sample subject"

'rmail("body")=body

'set arr = runner_mail(rmail)

' if error happened print a message on the web page

if arr("mailed") then

response.Write "Error happened:
"

response.Write "File: " & arr("source") & "
"

response.Write "Line: " & arr("number") & "
"

response.Write "Description: " & arr("description") & "
"

end if

end if

end if
' Place event code here.

' Use "Add Action" button to add code snippets.

Sergey Kornilov admin 6/25/2009

You need to run a SQL query retrieving description value from another table.
Use Data Access Layer for this purpose:

http://www.xlinesoft.com/asprunnerpro/docs...ccess_layer.htm