Forum Discussion
- srigudavOccasional ContributorHi All,
hank you for the updates. I was able to do by the below code.
Sub ReadExcel
QryXls_GetData("C:\driversheet.xls")
End Sub
'sFileName= xls file name with path
'Sheetname = table name
'VRstatmt = where statment for query
'Colname=Column name to fetch value from
'==============================================
Public Function QryXls_GetData( sFileName)
Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adCmdText = "&H0001"
sql_text="Select * FROM [driver$]where [Scenario Required]='yes'"
'1) Create an ADODB connection and recordset
Set objConnection = CreateObject("ADODB.Connection")
msgbox(sFileName)
'2) Open connection'
objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & sFileName & ";" & "Extended Properties=""Excel 8.0;HDR=Yes;"";"
'3) Create a Recordset'
Set objRecordSet = CreateObject("ADODB.Recordset")
'4) Execute SQL and store results in reocrdset'
objRecordset.Open sql_text , objConnection, adOpenStatic, adLockOptimistic, adCmdText
'5) Read all fields data and store in a array'
'For Multiple records
'=================
ReDim SQLExpectedData(objRecordset.recordcount -1)
For i=0 to objRecordset.recordcount -1 'objRecordset.fields.item(1).properties.count
SQLExpectedData(i)= objRecordset.fields("Test case")
functionname = "call "& objRecordset.fields("Test case")
msgbox (functionname)
execute functionname
objRecordset.movenext
msgbox(SQLExpectedData(i))
Next
'6) Close and Discard all variables '
objRecordset.Close
objConnection.Close
End Function - srigudavOccasional ContributorHi Ravi,
Only intenion for using this is as on today we are looking at Excel, May be infuture if we chage to SQl also i thought this will be having minimal changes.
Please correct me if my undersatnding is wrong. I have very minimal knowledge on this.
Thanks in Advance. - NisHeraValued ContributorCan you please mention how would u expect to develop tests...
is it KDT or scripting?
if scripting which language? - srigudavOccasional ContributorHi,
Sorry for not mentioning the details.
I would like to know using VB scripting - Marsha_R
Champion Level 3
It will be something like this:
While Not testingsheet.IsEOF
If (testingsheet.Value("Test Case required") = "Yes") Then
' use scenario to do test
End If
Call testingsheet.Next
WEnd
- RavikSuper ContributorHi Srikala Gudavalli,
I don't understand, for reading data from excel why you create -
'1) Create an ADODB connection and recordset
2- Open connection'
objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & sFileName & ";" & "Extended Properties=""Excel 8.0;HDR=Yes;"";
3)- Create a Recordset'
'4) Execute SQL and store results in reocrdset'
have you used Open Office instead of Microsoft Office or using "Office Starter" .
because normally we want to work with Microsoft Office (Excel) we can create object of Excel like below
Set Exo = CreateObject("Excel.Application") ot
Set Exo = Sys.OleObject("Excel.Application")
Exo.Workbooks.Open("Excel File Path")
.
.
.
.
Could you please share/Explain it in more.
Thanks
Ravik - RavikSuper ContributorThanks for clarification. :)