我是ASP的新手,并且有一个表单,允许用户从访问数据库中填充的下拉框中选择一个部门代码。一旦他们选择了该部门,我希望能够从同一记录集中收集其他字段(名称,地址,城市,州,邮政编码),并将这些字段传递给另一个asp页面。我能够将选定的代码写入数据库,但无法弄清楚如何从表中的特定行收集其他字段。我的代码是
<%
Set objconn = Server.CreateObject("ADODB.Connection")
objconn.ConnectionString = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("data/jobdata.mdb")
objconn.Open
Set objRs = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM EagleLocations "
objRs.Open strSQL, objconn
Response.Write "<select name=DCode><option value='' selected></option>"
Do While Not objRS.EOF
Response.Write "<option value='" & objrs("DCode") &"'>"& objRs("DCity") &"</option>"
objRS.MoveNext
Loop
Response.Write "</select>"
objRs.Close
objconn.Close
%>
如何让页面从所选DCode获取DName,DAddress1,DAddress2,DCity,DState和DZIP字段?
这是我的接收页面代码,我正在尝试从上一页的表单中获取数据以写入其他数据库:
<%
Dim objconn,strSQL,objRS
Set objconn = Server.CreateObject("ADODB.Connection")
objconn.open "PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("data/jobdata.mdb")
Set objRS = Server.CreateObject("ADODB.Recordset")
strSQL= "SELECT * FROM EagleLocations where Dcode =" & Request.Form("DCode")
objRs.Open strSQL, objconn
DIM strjobstart, strpm, strdcode, strdname, strcustname, strjobsite, strjobsubject, strworkmancompcode
strjobstart = Request.Form("jobstart")
strpmcode = Request.Form("pmcode")
strdcode = Request.Form("dcode")
strdname = Request.Form("dname")
strcustname = Request.Form("listcustname")
strjobsite = Request.Form("listjobsite")
strjobsubject = Request.Form("jobsubject")
strworkmancompcode = Request.Form("workmancompcode")
IF strjobstart <> "" AND strpmcode <> "" AND strdcode <> "" AND strcustname <> "" AND strjobsite <> "" AND strjobsubject <> "" AND strworkmancompcode <> "" THEN
' Process the form as you like here
' For example enter form to your database or send it via email
jobstart = request.form("jobstart")
pmcode = request.form("pmcode")
dcode = request.form("dcode")
dname = request.form("dname")
custname = request.form("listcustname")
jobsite = request.form("listjobsite")
jobsubject = request.form("jobsubject")
workmancompcode = request.form("workmancompcode")
Set Cnn = Server.CreateObject("ADODB.Connection")
Cnn.open "PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("data/jobcode.mdb")
strSql = "INSERT INTO JobCodeTemp (jobstart,pmcode,dcode,dname,custname,jobsite,jobsubject,workmancompcode) values( '" & jobstart & "' , '" & pmcode & "' , '" & dcode & "' , '" & dname & "' , '" & custname & "' , '" & jobsite & "' , '" & jobsubject & "' , '" & workmancompcode & "' )"
Cnn.Execute(strSql)
Cnn.Close
Set Cnn = Nothing
'Redirect to the index.asp page
Response.Redirect "display.asp"
csarafin