<%
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"
'Use Access Database
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) to open the record set
'If a specific id request is read, it is displayed
If Len (Request. QueryString ("id") <> 0 Then
'Read the corresponding record by id
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
'The record set is read cyclically and the result is displayed.
If Not objRS. EOF Then
ObjRS. MoveFirst
'The following table calls the id content in QueryString.
%>
<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, create a selection tag for the employee id and set the corresponding value
%>
<Option value = "<% = objRS. Fields (" id ") %>"> <% = objRS. Fields ("name") %> </OPTION>
<%
'Get the 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
%>