<% Remote ============================== = file name: clsconn.asp remote = function: Database Link Class REM = Number: REM = Function: Rem = author: shenzhe (QQ: 31477177 mail: shenzhe __ @ Hotmail.com) Rem = Last Update: 2005-2-3 Rem ============= ================
Class Clsconn
Private flag 'flag = 1: AC database flag = 0: sql database Private connStr' connect string '___________sql database parameters _____________ Private sqlDataBaseName' sqlserver database name Private sqlUser 'sqlserver database username Private sqlPassword' sqlserver database password Private sqlLocalName ' Link name, local use of Local IP
'------------- Access database related parameters ---------- Private DataPath' Access data inventory placed at the address "________ initialization class _____________prate sub coplassInitialize () SqlDatabaseName = "SQLUSER =" "Sqlpassword =" "SqllocalName =" "DataPath =" "Flag =" "Connstr =" "End Sub
'__________ class end _____________prate sub classterminate () End Sub
Public property Let Flag_ (iflag) Flag = iflag End Property
Public property let DataPath_ (iDataPath) DataPath = iDataPath End Property
Public property let sqldatabaseName_ (isqldatabaseName) SqlDatabaseName = IsqldatabaseName End Property
Public property let sqluser_ (isqluser) SQLUSER = isqluser End Property
Public property let sqlpassword_ (isqlpassword) sqlpassword = isqlpassword end tycalname_ (isqllocalname) sqllocalname = isqllocalName End Property
Public property get iconnstr () iconnstr = connStr End Property
'A link parameters __________ _________ Public Sub ConnStr_ () If flag = 1 Then connstr = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source =" & Server.MapPath (dataPath) Else connStr = "Provider = sqloledb; User ID = "& SQLUSER &"; Password = "& Sqlpassword &"; Initial Catalog = "& SqlDatabaseName &"; Data Source = "& SqllocalName &" End If Sub
'__________ establish a link ____________ Public Function OpenConnect () Dim tempConn On Error Resume Next Set tempConn = Server.CreateObject ( "ADODB.Connection") tempConn.Open connStr Set OpenConnect = tempConn Set tempConn = nothing
If Err.Number <> 0 Then Err.Clear Set OpenConnect = Nothing 'response.redirect ("")' Steering Custom Error page Response.write ("Error ..") response.end () end if end function
END CLASS%>