Quote:
|
Originally Posted by NonLinear
Is there any method to use ASP (or anything else method) to retrieve the text mesages from a database?
|
open a ado connection to the db, run a query, write the query output
this code takes a 4 digit input and returns four names.
Code:
<html>
<body OnLoad="document.getcode.agentcode.focus();">
<%
dim agentcode, puw, cuw, query, rs, conn, routepath, routefile, routename
dim tries, sqlconn, prt, crt
routepath = "c:\tasks\"
routename = "actagt2.mdb"
routefile = routepath & routename
if request.querystring("agentcode") = "" then
agentcode = "n/a"
else
if len(request.querystring("agentcode")) = 4 and isnumeric(request.querystring("agentcode")) then
agentcode = request.querystring("agentcode")
else
agentcode = "n/a"
response.write "<font color=red><b>Agent Code must be a four digit number</b></font><br>"
end if
end if
set conn = CreateObject("ADODB.Connection")
set sqlconn = CreateObject("ADODB.Connection")
set rs = CreateObject("ADODB.Recordset")
tries = 0
do
conn.open "DRIVER={Microsoft Access Driver (*.mdb)};" &_
"DBQ=" & RouteFile & ";DefaultDir=;UID=;PWD=;"
tries = tries + 1
Loop While (Err.Number<>0) And tries < 10
sqlconn.open "PROVIDER=SQLOLEDB;DATA SOURCE=imagergt;UID=sa;PWD=xxx;DATABASE=ImgRight"
query = "Select ENDT from MYTABLE where AGENT = '" & agentcode & "01'"
rs.open query, conn
if rs.eof then
if not agentcode = "n/a" then
response.write "<font color=red><b>Agent Code not found</b></font><br>"
end if
puw = "none found"
prt = puw
rs.close
else
puw = rs(0).value
rs.close
query = "Select ENDT from MYTABLE where AGENT = '" & PUW & "'"
'response.write query
rs.open query, conn
if rs.eof then
prt = "none found"
rs.close
else
prt = rs(0).value
rs.close
query = "select username from irsysusers where adjid = '" & prt & "'"
rs.open query, sqlconn
prt = rs(0).value
rs.close
end if
query = "select username from irsysusers where adjid = '" & puw & "'"
rs.open query, sqlconn
puw = rs(0).value
rs.close
end if
query = "Select ENDT from MYTABLE where AGENT = '" & agentcode & "12'"
rs.open query, conn
if rs.eof then
cuw = "none found"
crt = cuw
rs.close
else
cuw = rs(0).value
rs.close
query = "Select ENDT from MYTABLE where AGENT = '" & CUW & "'"
rs.open query, conn
if rs.eof then
crt = "none found"
rs.close
else
crt = rs(0).value
rs.close
query = "select username from irsysusers where adjid = '" & crt & "'"
rs.open query, sqlconn
crt = rs(0).value
rs.close
end if
query = "select username from irsysusers where adjid = '" & cuw & "'"
rs.open query, sqlconn
cuw = rs(0).value
rs.close
end if
sqlconn.close
conn.close
response.write "Agent Code - " & agentcode & "<br>Personal UW - " & puw & "<br>Commerical UW - " & cuw
response.write "<br><BR> Personal Rater - " & prt & "<br> Commerical Rater - " & crt %>
<br><br>
<form action=" <%= request.servervariables("URL") %>" method="get" name="getcode">
Enter Agent Code:<br>
<input type="text" name="agentcode">
<input type="submit" value="Get UWs & Raters">
</form>
</body>
</html>
Quote:
|
How can I pass data that come from server side scripting to the client javascript code?
|
use response.write in server code to write the output that the client receives.
this code would create a dynamic drop down list
Code:
function getuwlist
query = "Select uw, uwadj from underwriters order by uwadj"
rs.open query, conn
if rs.eof then
getuwlist = "<option>NO UWS FOUND</option>"
exit function
else
do until rs.eof
getuwlist = getuwlist & "<option>" & rs.fields("uwadj").value & "-" & rs.fields("uw").value & "</option>"
rs.movenext
loop
getuwlist = getuwlist & "</select>"
end if
end function