<!--
Frog Frogs recommended: VBS database Operations class, this class implements the usual major database operations, because we are dealing with the database every day, sometimes it is convenient to use such a class, but do not know how practical, because in the performance and error handling has not done a lot of consideration, so do not know how its versatility.
It is even more perfect if someone can add dynamic error handling to the class or optimize performance. PS: This class is also to practice the use of the VBS class.
-->
<%
Class Classado
Private Conn_c
Private Rs_c
Public strconn
Private Sub Class_Initialize ' defines initialization events for classes
End Sub
Private Sub class_terminate ' sets Terminate event.
' Define the purge event for the class
Rs_c.close
Set rs_c=nothing
Conn_c.close
Set conn_c=nothing
End Sub
Public Function opendb () Open database
If IsEmpty (strconn) Then
Response. Write ("No database connection string Set")
Response.End
End If
If IsEmpty (Conn_c) Then
Set conn_c=server.createobject ("ADODB. Connection ")
Conn_c.open strconn
Else
Response. Write ("Database is already open")
Response.End
End If
End Function
Public Function getrs (ByVal strSQL) ' Get recordset
If IsEmpty (Conn_c) Then
OPENDB ()
End If
Set rs_c=server.createobject ("ADODB. RecordSet ")
Rs_c.open strsql,conn_c,1,1
Set Getrs=rs_c
End Function
Public Function Exesql (ByVal strSQL) ' executes an SQL statement for inserting, updating, deleting records
If IsEmpty (Conn_c) Then
OPENDB ()
End If
Conn_c.execute (strSQL)
End Function
End Class
%>
<%
' On Error Resume Next ' When debugging the program, please remove this sentence
strconn= "Driver={sql Server};server=192.168.0.110;database=northwind;uid=sa;pwd=sa;"
Set C=new Classado
C.strconn=strconn
C.OPENDB ()
Strsql= "SELECT Employeeid,titleofcourtesy +" + LastName + "+ FirstName as FullName from Employees"
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.