need to read λ from excel file.
We are automating a desktop application where in i need to select 'Index λ' and 'Value λ' input on application.
These inputs are kept in excel file. For reading i have written fnction using ADODB connection object.
For reading such characters what needs to be done? This character is not reconized by the read function.
Can somebody please help me on this?
Below is my code for reading excel.
Function ReadInputFromExcel_MultipleSettings(sheetName, settingName, columnName)
On Error Resume Next
log.Message "In ReadInputFromExcel_MultipleSettings function"
Dim objAdCon, objAdRs
Dim arr:arr = Array()
log.Message settingName
strFileName = Project.Variables.InputFilePath
'strFileName = "C:\Count and Measure\TestExecutionInputs\TestSuite_Driver_Input.xls"
log.Message strFileName
Call closeExcel
'strSQLStatement = "Select AllFramesAndChanells from [General$] where SettingName='General_def'"
strSQLStatement1 = "Select * from ["& sheetName &"$] where SettingName = '"& Trim(settingName) &"'"
log.Message strSQLStatement1
Set objAdCon = CreateObject("ADODB.Connection")
objAdCon.Open "DRIVER={Microsoft Excel Driver (*.xls)};DBQ="&strFileName & ";Readonly=True"
'objAdCon.Open "DRIVER={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ="&strFileName & ";Readonly=True;"
If Err <> 0 Then
log.Message objAdCon.State
Log.Message Err.Number
Log.Message Err.description
objAdCon.Close
objAdCon = nothing
End If
Set objAdRs = CreateObject("ADODB.Recordset")
objAdRs.Open strSQLStatement1, objAdCon
AqUtils.Delay 500
If Err <> 0 Then
log.message Err.Number
log.Message Err.Description
If objAdRs.State = adStateOpen then
log.Message objAdRs.State
objAdRs.close
End If
If objAdCon.State = adStateOpen Then
log.Message objAdCon.State
objAdCon.Close
End If
objAdRs = Nothing
objAdCon = Nothing
log.Error "Create Connection Error",Err
Exit function
End If
'get multiple settings value
mulsettings = objAdRs("MultipleSettings").Value
log.Message mulsettings
If mulsettings = "Yes" then
log.message objAdRs("TotalSettings").Value
totset = objAdRs("TotalSettings").Value
for i=1 to totset
'log.Message i
strSQLStatement2 = "Select "& columnName &" from ["& sheetName &"$] where SettingName = '"& Trim(settingName) &"' AND SrNo=" & i & " "
'strSQLStatement2 = "Select "& columnName &" from ["& sheetName &"$] where SettingName = '"& Trim(settingName) &"' AND SrNo= '" & i & "'"
'log.Message strSQLStatement2
Set objRS = objAdCon.Execute(strSQLStatement2)
'log.Message objRS.RecordCount
If objRS.EOF Then
log.message "No items found"
Else
objRS.MoveFirst
Do While Not objRS.EOF
'log.message objRS.Fields(columnName).value
ReDim Preserve arr(Ubound(arr) + 1)
arr(UBound(arr)) = objRS.Fields(columnName).value
objRS.MoveNext()
Loop
End If
next
end if
objAdRs.close
objAdCon.Close
Set objAdRs = Nothing
Set objAdCon = Nothing
Call closeExcel
ReadInputFromExcel_MultipleSettings = arr
End function
Thanks and Regards,
Swati Nadage
By changing provider to Microsoft Jet Oledb it solved the problem. Jet has built in support for unicode.