when trying to retrieve multiple values from database in qtp, it is not returning any values even after connection is established.

  • Questions
  • when trying to retrieve multiple values from database in qtp, it is not returning any values even after connection is established.
Question ID: 105956
0
0

i am trying to retrieve multiple values from database and save it in datatable. it is not returning any values .

Marked as spam
Posted by (Questions: 1, Answers: 3)
Asked on February 26, 2015 11:21 am
7 views
Answers (3)
0
Private answer

Post a copy of your query code. Are you absolutely sure your query is finding data? Have you tested the query through another interface? What version of the product are you using?

Marked as spam
Posted by (Questions: 1, Answers: 101)
Answered on February 26, 2015 5:43 pm
0
Private answer

hi,
yes i am sure that query is finding data. When i am using that query in sql Developer it is returning appropriate data. Actually the problem is when i am trying to fetch multiple values it is hot returning anything. And when i am trying to fetch single value, it is returning expected value.
Also, the problem is with 32 bit machine. Same code for fetching multiple vales is working in 64 bit machine.

I have installed oracle client 11g in my machine.

Marked as spam
Posted by (Questions: 1, Answers: 3)
Answered on February 27, 2015 6:12 am
0
Private answer

I am using below code:-
Function FetchValue_DataSource_AllValue_DataTable(strDataSource,strSqlQuery)

On Error resume Next
Dim oCon, oRes

err.clear
Set oCon = CreateObject(''ADODB.Connection'')
Set oRes = CreateObject(''ADODB.Recordset'')
oCon.Open strDataSource
If oCon.State = 1 Then
Set oRes = oCon.Execute(strSqlQuery)
oRes.Open strSqlQuery, oCon,3,3,1
If oRes.EOF = ''False'' Then
oRes.MoveFirst
intmaxCount = oRes.RecordCount
intColCount = oRes.Fields.Count
For j = 0 To intColCount -1 Step 1
datatable.LocalSheet.AddParameter oRes.Fields(j).Name,''''
Next
For i = 0 to intmaxCount-1
datatable.LocalSheet.SetCurrentRow(i+1)
For j = 0 To intColCount -1 Step 1
strDTColName = oRes.Fields(j).Name
strDBColName = oRes.Fields(j).Name
' If Instr(1,strDTColName, Then strDTColName = ''COUNT''
If strDTColName = ''COUNT(*)'' Then strDTColName = ''COUNT''
If IsNumeric(Mid(strDTColName,1,1)) Then strDTColName = ''_'' & strDTColName
datatable.Value(strDTColName,dtLocalSheet) = oRes.Fields(strDBColName).Value
Next
oRes.MoveNext
Next
Else
result= ''Null''
end If
Else
Call Sub_WriteToResultsLog(1,''Not able to connect with DB, Please Verify Manually'','''')
result= ''Null''
End If

If err.number <> 0 Then result= ''Null''

FetchValue_DataSource_AllValue_DataTable = result

If oRes.State = 1 Then oRes.Close
If oCon.State = 1 Then oCon.Close

Set oRes = Nothing
Set oCon = Nothing

On Error Goto 0

End Function

Marked as spam
Posted by (Questions: 1, Answers: 3)
Answered on February 27, 2015 6:16 am
I don't see anything obviously wrong. One thing you could try is commenting out the ''On Error'' statements, then run the code again to see if any exceptions surface.
( at February 27, 2015 5:24 pm)