I am an automation developer with 7 years of experience. I have worked on multiple industry leading automation tools. I am interested in the development of new tools, frameworks and methodologies.
1) you can use the data table object of the UFT and generate the results in the datatable of UFT. Once the results are generated you can export the results to excel.
2) you can use the excel vba to generate the excel sheet at runtime and save it at the end of the execution.
You can start googling about it using
Createobject(“excel.application”)
Please let me know if you are looking for something specific.
You will have to use the Adodb.Connection and Adodb.Recordset objects for retrieving the results from any database.
You will also have to search and use the right connection string for the database type.
below is the vbs code for connecting to oracle data base
Dim strCon
strCon = “Driver={Oracle in Oracle in Orahome10g}; ” & _
“CONNECTSTRING=(DESCRIPTION=” & _
“(ADDRESS=(PROTOCOL=TCP)” & _
“(HOST=SERVERNAME)(PORT=1521))” & _
“(CONNECT_DATA=(SERVICE_NAME=TEST))); uid=username;pwd=password;”
Dim oCon: Set oCon = WScript.CreateObject(“ADODB.Connection”)
Dim oRs: Set oRs = WScript.CreateObject(“ADODB.Recordset”)
oCon.Open strCon
Set oRs = oCon.Execute(“SELECT 1 from dual”)
While Not oRs.EOF
WSCript.Echo oRs.Fields(0).Value
oRs.MoveNext
Wend
oCon.Close
Set oRs = Nothing
Set oCon = Nothing
Need notes on how to export uft result to excel sheet
LikeLiked by 1 person
Hi Prasanna
You can do it in two ways
1) you can use the data table object of the UFT and generate the results in the datatable of UFT. Once the results are generated you can export the results to excel.
2) you can use the excel vba to generate the excel sheet at runtime and save it at the end of the execution.
You can start googling about it using
Createobject(“excel.application”)
Please let me know if you are looking for something specific.
LikeLike
Hi sumeeth, give me knowledge on Database connection with uft using ADODB connection string and how to retrieve result from the database
LikeLike
Hi Prasanna,
You will have to use the Adodb.Connection and Adodb.Recordset objects for retrieving the results from any database.
You will also have to search and use the right connection string for the database type.
below is the vbs code for connecting to oracle data base
Dim strCon
strCon = “Driver={Oracle in Oracle in Orahome10g}; ” & _
“CONNECTSTRING=(DESCRIPTION=” & _
“(ADDRESS=(PROTOCOL=TCP)” & _
“(HOST=SERVERNAME)(PORT=1521))” & _
“(CONNECT_DATA=(SERVICE_NAME=TEST))); uid=username;pwd=password;”
Dim oCon: Set oCon = WScript.CreateObject(“ADODB.Connection”)
Dim oRs: Set oRs = WScript.CreateObject(“ADODB.Recordset”)
oCon.Open strCon
Set oRs = oCon.Execute(“SELECT 1 from dual”)
While Not oRs.EOF
WSCript.Echo oRs.Fields(0).Value
oRs.MoveNext
Wend
oCon.Close
Set oRs = Nothing
Set oCon = Nothing
You can find the desired connection strings below
http://www.connectionstrings.com/
let me know, if you need any other details.
LikeLike