Forum Discussion
Thanks Robert,
I tried adding that and its giving me :object does not support this method or poerpoerty "Qry1.Fields"
Updated my code as below
Function Sq_Qry(value )
'Create a query
'
Set Qry1 = ADO.CreateADOQuery
'Specify the connection string
Qry1.ConnectionString = "Provider=IBMDA400.DataSource.1;Persist Security Info=False;User ID=XXX;Password=XXX;Data Source=XXX"
'Specify the SQL expression
'Qry1.SQL="Select * FROM schema.table"
Qry1.SQL=value
'Execute the query
Qry1.Open()
'Process results and insert data into the test log
Qry1.First()
'Obtains field names
while Not Qry1.EOF
for i=0 to Qry1.Fields.Count
Set test=Qry1.Fields.Item(i).Value
Next
'Log.Message(Qry1.SQL.Value)
Qry1.Next()
Wend
Log.Message(test)
'Closes the query
Qry1.Close()
errCode =0
End Function
My bad... try instead
Qry1.FieldByName('<column name>').Value
- GAutomation7 years agoFrequent Contributor
Robert,
I tried with that also same error. should i use ADOConnection instead of query?
tried with field,fields,fieldbuname,fieldcount
it is not recongnising qry1.Fields
- tristaanogre7 years agoEsteemed Contributor
Right... notice that I changed the code to not use Qry1.Fields at all.
It's Qry1.FieldByName instead... that's the proper code for that object.
https://support.smartbear.com/testcomplete/docs/reference/program-objects/ado/createadoquery.html- GAutomation7 years agoFrequent Contributor
Thanks Robert,
It works fine if i give the specfic column name and it is displaying that column name values.
but in my query i am giving select * from table name which will pul all column values right?
so in the log results too i want all the column values
if i given Log.message Qry1.FieldByName.item(i).Value it is not working.