Execute SQL Query

How to execute SQL Query in QTP with VBScript?

Questions by sindhusai

Showing Answers 1 - 6 of 6 Answers

priyankvyas

  • May 11th, 2009
 

Hi this is priyank,


This is code to run sql query through qtp.

SQL="SELECT * FROM ORDERS"
connection_string="QT_Flight32"

columns=1
set connection = CreateObject("ADODB.Connection")
connection.Open connection_string

set rs1 = connection.Execute( SQL )
rows=db_get_rows_count(rs1)
msgbox rows
 rows=rows-1
 myval=db_get_field_value(rs1 , rows , columns )
msgbox myval

here the hilighted code is to set connection to DSN and than execute query on existing DSN.

  Was this answer useful?  Yes

We can execute SQL query like

dim conn,rs
set conn=createobject(ADODB."connection")
set rs=createobject(ADODB."recordset")$
conn.provider(Microsoft.jet.oledb4.0)? "it is provider"
conn.open(D:sekhar/ramesh.)
rs.open "select * from orders",conn.
while <>rs.EOF
msgbox rs.fields(1)
rs.movenext
wend

correct me, if any mistake.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions