Option explicit Dim comobj, conobj Set conobj=createobject("ADODB.Connection") conobj.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Sai Sarvani\Desktop\ sample.mdb" Set comobj=createobject ("ADODB.Command") comobj.activeconnection = conobj comobj.commandtext = "Insert into emp values ('Appa Rao', 101, 10000)" comobj.execute conobj.close Set comobj = nothing Set conobj = nothing How to set multiple records into database table by taking the data from Excel file Option explicit Dim comobj,conobj,rcount,i,ename,eno,esal Set conobj=createobject("ADODB.Connection") conobj.open "PRovider=Microsoft.jet.oledb.4.0; data Source = C:\Documents and Settings\Sai Sarvani\Desktop\ sample.mdb" Set comobj=createobject("ADODB.Command") comobj.activeconnection=conobj datatable.AddSheet ("data")
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
reporter.ReportEvent micPass, "Login success", "Test is Pass" Window("Flight Reservation").WinMenu("Menu").Select "File;Exit"
else
reporter.ReportEvent micFail, "Login Fail", "Test is fail" Dialog("Login").Dialog("Flight Reservations").WinButton("OK").Click Dialog("Login").WinButton("Cancel").Click
End If rsobj.movenext
Wend
rsobj.close conobj.close
Set rsobj=nothing
Set Conobj=nothing
QTP- Execute the bat file , dos command from QTP dim appset app=createobject("wscript.shell")SystemUtil.run "cmd.exe"app.sendkeys "cd C:\Documents and Settings\'<>\"app.sendkeys "~"app.sendkeys "MyDosFile.bat"app.sendkeys "~" app.sendkeys "~"wait(5)
'In bat file you can give and saveDateecho "hello World"pause
QTP/QC - Schedule the testset in QC by VBS 'User must Admin at the machine where he want to run the testset'This can run manual as well as Automated test suite' It can be schedule at any partcular future time' User need not to open the QC
Public Sub RunTestSet(otdc,tsFolderName,tSetName,HostName,runWhere)
Dim TSetFact, tsListDim theTestSetDim tsTreeMgrDim tsFolderDim SchedulerDim nPathDim execStatus' Get the test set tree manager from the test set factory'tdc is the global TDConnection object.Set TSetFact = otdc.TestSetFactorySet tsTreeMgr = otdc.TestSetTreeManager' Get the test set folder passed as an argument to the example codenPath = "Root\" & Trim(tsFolderName)Set tsFolder = tsTreeMgr.NodeByPath(nPath)If tsFolder Is Nothing Thenerr.Raise vbObjectError + 1, "RunTestSet", "Could not find folder " & nPathEnd If' Search for the test set passed as an argument to the example codeSet tsList = tsFolder.FindTestSets(tSetName)If tsList Is Nothing Thenerr.Raise vbObjectError + 1, "RunTestSet", "Could not find test set in the " & nPathEnd IfIf tsList.Count > 1 ThenMsgBox "FindTestSets found more than one test set: refine search"Exit SubElseIf tsList.Count < 1 ThenMsgBox "FindTestSets: test set not found"Exit SubEnd If
Set theTestSet = tsList.Item(1)Debug.Print theTestSet.ID'Start the scheduler on the local machineSet Scheduler = theTestSet.StartExecution(HostName)
'msgbox "pass"
'Set up for the run depending on where the test instances
' are to execute.
Select Case runWhere
Case "RUN_LOCAL"'Run all tests on the local machineScheduler.RunAllLocally = TrueCase "RUN_REMOTE"'Set Scheduler = theTestSet.StartExecution(HostName)
'Run tests on a specified remote machineScheduler.TdHostName = HostName
'Scheduler.TdHostName=runWhere' RunAllLocally must not be set for
' remote invocation of tests.' Do not do this:' Scheduler.RunAllLocally = FalseCase "RUN_PLANNED_HOST"'Run on the hosts as planned in the test setDim TSTestFact, TestListDim tsFilterDim TSTst'Get the test instances from the test setSet TSTestFact = theTestSet.TSTestFactorySet tsFilter = TSTestFact.FiltertsFilter.Filter("TC_CYCLE_ID") = theTestSet.IDSet TestList = TSTestFact.NewList(tsFilter.Text)Scheduler.RunAllLocally = FalseEnd Select'Run the testsScheduler.runSet execStatus = Scheduler.ExecutionStatusWhile (RunFinished = False)execStatus.RefreshExecStatusInfo "all", TrueRunFinished = execStatus.Finished
WendEnd Sub'================================Const qcHostName = "GiveQChost:8080"Const qcDomain = "GiveDomain name"Const qcProject = "GiveProject" 'Please define here the name of the projectConst qcUser = "User ID" 'Please define here the usernameConst qcPassword = "Give Password HGBGH%3&42" 'Please define here the password
Dim tdcDim qcServer
Dim objArgsDim strArgDim strTestSetDim bRunCode
'======GETTING ARGUMENTS==============set objArgs = WScript.ArgumentsIf WScript.Arguments.Count<1>2 ThenWScript.Echo "Remote_Scheduler"bRunCode = FalseElseFor Each strArg in objArgsWScript.Echo strArg&" is starting…"strTestSet = strArgbRunCode = TrueNextEnd If
'===========================================================If bRunCode ThenqcServer = "http://" & qcHostNameqcServer = qcServer & "/qcbin"Set tdc = CreateObject("tdapiole80.tdconnection")If (tdc Is Nothing) ThenMsgBox "tdc object is empty"End Iftdc.InitConnectionEx qcServertdc.Login qcUser, qcPasswordtdc.Connect qcDomain, qcProjectRunTestSet tdc, "GiveFolder Name of Test Set","GiveTestSet name ","Givemachinename", "RUN_REMOTE"'Disconnect from the projectIf tdc.Connected Thentdc.DisconnectEnd If'Log off the serverIf tdc.LoggedIn Thentdc.LogoutEnd If'Release the TDConnection object.
tdc.ReleaseConnection'"Check status (For illustrative purposes.)
QTP/QC - Running bat file from QC Povide the bat file 'Driverbat.bat' remove ' sign and put bat under folder C:\QTP_Resource.'cd C:\QTP_Resource'DriverScript_QTP'C:\QTP_Resource\Utility2.exe auto some other utility'Exit
In QC > Create a VAPI-XP test > in test script put the code
Dim objShellSet objShell = CreateObject("WScript.Shell")'objShell.Run "CMD.exe"objShell .Run "%comspec% /k c: & cd C:\QTP_Resource Driverbat.bat"BR>'objShell.Run "%comspec% /k c: & cd C:\QTP_Resource\\Driverbat.bat"BR>'qtAppWin.sendkeys "~"