<%
1
Set cn = server. createobject ("adodb. connection ")
Object cn used to create a database connection
2
Cn. open "... con_str ..."
Call the open method of cn and use the string in the middle of double quotation marks as a parameter to open the database (you need to open the database before the operation is complete, and then you need to close it to call the close method of cn ). You can also choose to use the system or user data source, but it is not recommended because many times you do not have operation permissions on the virtual host, so use the connection string.
3
Set rs = server. createobject ("adodb. recordset ")
Rs used to create a data record
4
Strsql = "select * from product where product_name =" & request ("name ")&""
Write SQL statements for specific functions and assign them to the variable strsql
5
Set rsw.cn.exe cute (strsql)
Use strsql as the parameter to call the execute method of cn to connect the database of cn to execute the SQL statement stored in the variable strsql, and assign the query results (all Qualified Data Records) obtained after the statement is executed to the record set object rs. Of course there are many other methods, use it after you are familiar with other methods of other objects.
The database does not have any matching records.
6
Do until rs. eof
Response. write rs ("product_name ")
Rs. movenext
Loop
The data in the dataset is stored in the format of rs. bof --- data record 1 --- data record 2 --- data record 3 ...... Data Record n --- rs. eof; display the product_name field values in all rs record sets one by one using a loop statement
7
Rs. colse
Disable record set and release memory
Cn. close
Close the connection and release the memory. These are the key points. Otherwise, the server consumption will increase.
%>