Forum Discussion
9 Replies
- GAutomationFrequent Contributor
after chaning the code to
Qry1.SQL=value it worked. But i need help to display the results that query is returning in log results. How can i achieve that.
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=exxx;Data Source=xxx"
'Specify the SQL expression
'Qry1.SQL="Select * FROM schema.tablename"
Qry1.SQL=value
Set Qryresult = qry1
'Log.Message(Qryresult)
'Execute the queryQry1.Open()
'Process results and insert data into the test logQry1.First()
'while Not Qry1.EOF
'return Qryresult
'Log.Message(Qry1.SQL.Value)
'Qry1.Next()'Wend
'Closes the query
Qry1.Close()End Function
- tristaanogreEsteemed Contributor
Try
Qry1.Fields.Item('<column name>').Value
This should return the contents of the column name indicated.
- GAutomationFrequent Contributor
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- tristaanogreEsteemed Contributor
My bad... try instead
Qry1.FieldByName('<column name>').Value