Public feed #378744

Mine

public text v1 · immutable
Raw Edit
·published 2007-03-02 19:02 UTC
rendered paste body
<!--#include file = "adovbs.inc" -->
<%

Class dbClass

 ' Declare Private Variables
 Private pRecordSet
 Private pAdodbConnection
 Private pConnectionString
 Private pSqlString


 Private Sub Class_Initialize()

  Set pSqlString = Nothing

  if isobject(pAdodbConnection) = false then

   Set pAdodbConnection = Server.CreateObject("ADODB.Connection")
   Set pRecordSet = Server.CreateObject("ADODB.Recordset")

   end if

 End Sub

 Private Sub Class_Terminate(  )

  if isobject(pRecordSet) = true then
   pRecordSet.Close
   Set pRecordSet = nothing
  end if

  if isobject(pAdodbConnection) = true then
   pAdodbConnection.Close
   Set pAdodbConnection = nothing
  end if

 End Sub


 ' GET & SET for ConnectionString Property

 Public Property Set ConnectionString( strCS )
        pConnectionString = strCS
 End Property

 Public Property Get ConnectionString( )
        ConnectionString = pConnectionString
 End Property

 'GET & SET for SQL String Property

 Public Property Set sqlString( strSQL )
        pSqlString = strSQL
 End Property

 Public Property Get sqlString( )
         sqlString = pSqlString
 End Property

 'GET for RecordSet
 Public Property Get RecordSet( )
         RecordSet = pRecordSet
 End Property

 ' runSQL( bResults )
 ' Method to execute a SQL statment against database connection.
 ' Method to execute SQL Statement
 ' INPUTS:
 '        bResults :
 '                  true : SQL returns result
 '                  false : SQL does not return result

 Public Function runSQL( bResults )

   cn.ConnectionString = pConnectionString
   cn.Open

  if bResults then

   Set pRecordSet = pAdodbConnection.Execute(pSqlString)
   pRecordSet.MoveFirst

  else

   pAdodbConnection.Execute(pSqlString)

  end if

 End Function

End Class

%>