Home
> Quick Test Pro > QTP Connection to Access DB
QTP Connection to Access DB
The below code illustrate the connection to Access Data Base.Here we are using the class concept as it helps us to organize the code.Class clsAccess‘ @HELP‘ @description: This class is defined to handle database operations.‘ @ENDDim objConnectionPublic Sub sub_ConnectToDatabase(strDBName,objConn)‘ @HELP‘ @class: clsAccess‘ @method: sub_ConnectToDatabase()‘ @returns: Returns state whether connection is established or not.‘ @notes: This function is used to connect MS Access database.‘ @ENDDim blnConnectionSet objConnection = CreateObject(“ADODB.Connection”)objConnection.Open(“DRIVER={Microsoft Access Driver (*.mdb)};DBQ=” & strDBName)blnConnection = objConnection.StateIf blnConnection = 1 ThenReporter.ReportEvent micPass, “Connection to Database”, “Connection to < “&strDBName& ” > is established. “Set objConn = objConnectionElseReporter.ReportEvent micFail, “Connection to Database”, “Connection to < “&strDBName& ” > is not established. “Exit SubEnd IfEnd Sub‘————————————————————————————————————————————Public Sub sub_DisconnectToDatabase()‘ @HELP‘ @class: clsAccess‘ @method: sub_DisconnectToDatabase()‘ @returns: None‘ @notes: This function is used to disconnect the connection to the MS Access database.‘ @ENDobjConnection.CloseEnd Sub‘————————————————————————————————————————————End Class‘Set cls = New clsAccess
Categories: Quick Test Pro
Comments (0)
Trackbacks (0)
Leave a comment
Trackback