|
I met problem as follow, when I read excel data from sheet1, column2, first 3 rows can be retrieved from QTP, but the row4, row 5 data couldnot get retrieved from QTP.
data in excel sheet1, column2---
Row0: Column2 ---> header
Row1: 1 ---> can be read
Row2: 2 ---> can be read
Row3: 3 ---> can be read
Row4: line5 ---> error happened here
Row5: line6 ---> error happened here
My scripts:
=====================================================================
Dim Connect1 'As New ADODB.Connection
Dim strQuery
Dim DataRecordSet
Dim arrFields(10)
Set Connect1 = Createobject("ADODB.Connection")
With Connect1
.Provider = "Microsoft.JET.OLEDB.4.0"
.ConnectionString = "Data Source = D:\QTP\MySpreadsheet.xls;Extended Properties=Excel 8.0;"
.Open
End with
' retrieve excel data value
'strQuery = "Select * from [" & strTableName & "$] where " & strColumnNM1 & " = " & "'" & strColValue1 & "'"
strQuery = "Select * from [Sheet1$] "
' msgbox strQuery
Set DataRecordSet = Connect1.execute (strQuery)
' DataRecordSet.movefirst
' set objField = DataRecordSet.Fields
Do While Not DataRecordSet.EOF
intRecordCount = intRecordCount + 1
CurrentValue = DataRecordSet("Column2").value
msgbox CurrentValue
DataRecordSet.MoveNext
Loop
Set DataRecordSet = nothing
Set Connect1= nothing
===============================================================
PS: excel saved on D:\QTP\MySpreadsheet.xls
Please all masters help me to solve this problem. |
|