Anyway, I have used this to make a lot of websites now, and I think it is still very useful, so I will share it with you. Supports three types of database connections: MSSQL2000, MSSQL2005, ACCESS
Three methods:
select_table(sql)
Table query, return TRUE or FALSE
Return FALSE when an SQL statement errors, or empty record, otherwise TRUE
update_table(SQL)
Table update, including update, delete
Return TRUE if successful execution, otherwise return FALSE if updated, and the number of rows affected after execution.
insert_table(sql,table,id_column)
table is the table name, id_column is the automatic number in the table, and the field is increased by itself.
Return TRUE when successful execution, otherwise return FALSE, specify TABLE, and ID_column, the auto-increment ID generated by the last added record will be returned.
Select_table() related method Select_page(page, psize)
Pagination processing, page is the current page, and psize is the number of rows recorded per page.
During all operations, the database link and RS are automatically detected whether it is open, and the database link will be automatically closed after execution.
Example:
setdb=newadodb_class
ifdb.select_table("select*fromnewsorderbyiddesc")then
page=request("page")
Select_page(page,20)'20 items per page
fori=1to20
response.writedb.rs("title")' class is built-in rs and is immutable
db.rs.movenext
ifdb.rs.eofthenexitfor
next
endif
db.rsPage=Total number of pages, db.nowPage=The current page after processing, db.rsCounts will count the total number of records.
ifdb.update_table("deletefromnewswhereispass=1")then'update the same
response.write "Delete"&db.updated&"row" in total
endif
calldb.insert_table("insertintonews(title,content)values('"&title&"','"&content&"')","news","id")
response.write"Last added the ID as "&db.Insertd
At the end of the page, you can output db.readCounts as the number of times the database is queryed.
--------------------------------------------
The advantage of this class is that you don’t have to worry about forgetting to close the database link, don’t need to setrs=server.recordset("adodb.recordset") frequently, don’t need to setrs=nothing
The disadvantage is the traditional way of turning pages. rs.absolutepage=rs.pagesize
----------------------------------------------------------
<%
'/******kshop*******/
'adodb_class.asp database operation class
'Version1.0
'Copyright[email][email protected][/email]
'E-mail[email][email protected][/email]