<%
Dim objDC, objRS
Set objDC = Server. CreateObject ("ADODB. Connection ")
ObjDC. ConnectionTimeout = 15
ObjDC. CommandTimeout = 30
'Create a database connection
ObjDC. open "DBQ =" & Server. mapPath ("database. mdb ") &"; Driver = {Microsoft Access Driver (*. mdb)}; DriverId = 25; MaxBufferSize = 8192; Threads = 20; "," username "," password"
'UseAccessDatabase
ObjDC. Open Application ("SQLConnString"), Application ("SQLUsername "),
Application ("SQLPassword ")
Set objRS = Server. CreateObject ("ADODB. Recordset ")
'Create and retrieve Record Sets
'Use forward cursor (0) And read-only mode (1) Open record set
'If the specifiedIdThe request is read.
If Len (Request. QueryString ("id") <> 0 Then
'AccordingIdRead the corresponding records
ObjRS. Open "select * from intelsdb WHERE id =" & Request. QueryString ("id"), objDC, 0, 1
'Show selected records
If Not objRS. EOF Then
ObjRS. MoveFirst
%>
<Table border = 2>
<Tr>
<Td> <B> ID </B> </td>
<Td> <B>Name</B> </td>
<Td> <B>Department</B> </td>
<Td> <B>Monthly sales</B> </td>
</Tr>
<Tr>
<Td ALIGN = "center"> <% = objRS. Fields ("id") %> </td>
<Td ALIGN = "left"> <% = objRS. Fields ("name") %> </td>
<Td ALIGN = "left"> <% = objRS. Fields ("department") %> </td>
<Td ALIGN = "right"> <% = objRS. Fields ("sales") %> </td>
</Tr>
</TABLE>
<%
End If
ObjRS. Close
End If
ObjRS. Open "intelsdb", objDC, 0, 1
'Read the record set cyclically and display the result
If Not objRS. EOF Then
ObjRS. MoveFirst
'The following table callsQueryStringLiIdContent
%>
<Form action = "./db_pulldown.asp" METHOD = "get">
<Select NAME = "id">
<OPTION> </OPTION>
<%
'Until the record set is read.
Do While Not objRS. EOF
'For each record, it is an employeeIdCreate a selection tag and set the corresponding value
%>
<Option value = "<% = objRS. Fields (" id ") %>"> <% = objRS. Fields ("name ")%> </OPTION>
<%
'Get next record
ObjRS. MoveNext
Loop
%>
</Select>
<INPUT type = "submit" value = "Submit">
</FORM>
<%
End If
'Close and clear
ObjRS. Close
Set objRS = Nothing
ObjDC. Close
Set objDC = Nothing
%>