0

I am trying to use excel as a database through QTP and trying to fetch records from it. I am running this code in windows 64 bit system and excel is 2010 version. Below is the code. Please help me what is the issue

Dim objCon, objRs
set objCon = createobject("ADODB.Connection")
objCon.Open "Provider = Microsoft.ACE.OLEDB.12.0;" & "Data Source = O:\Desktop\UFT\Testcases.xlsx;" & "Extended Properties = ""Excel 12.0 Xml;HDR = YES;"";" 

Set objRs = createobject("ADODB.Recordset")

objRs.Open "select count(*) from Sheet1 where status = 'Fail'", objcon

msgbox objRs(0)

Set objCon = nothing

Set objRs = nothing
Pramod Gharu
  • 1,105
  • 3
  • 9
  • 18
sankar05
  • 1
  • 1
  • 1
    https://www.connectionstrings.com/ace-oledb-12-0/xlsx-files/ : in the connection string remove the semicolon after `HDR = YES` : `.Open "Provider = Microsoft.ACE.OLEDB.12.0;" & "Data Source = O:\Desktop\UFT\Testcases.xlsx;" & "Extended Properties = ""Excel 12.0 Xml;HDR = YES"";"` – Axel Richter Aug 27 '16 at 11:55
  • Thanks Axel. It's working. – sankar05 Aug 28 '16 at 09:43

0 Answers0