Showing posts with label Database. Show all posts
Showing posts with label Database. Show all posts

Wednesday, February 15, 2012

Running Database Procedure using qtp

Following code can be used to execute the database procedure. Before proceeding you must know the connection-string to connect the database & the name of the procedure. If you dont know the connection-string of your database refer http://www.connectionstrings.com/ . This website provides an easy reference to connection-strings for various databases.








Set conn = CreateObject("ADODB.Connection")
Set adocommand = CreateObject("ADODB.Command")

conn.ConnectionString = "Connection-string of the running database"
conn.Open


Set adocommand.ActiveConnection = conn
adocommand.CommandText = "Name of the Stored Procedure"
adocommand.CommandTimeout = 30
adocommand.CommandType = 4

adocommand.Execute

conn.Close


Set adocommand = Nothing
Set conn = Nothing