Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Importing Data from a Database
#1
Solved: 11 Years, 3 Months, 3 Weeks ago
Hi Guys,

Is there any way to Automate the feature provided by QTP to import data from a Database Table to DataSheet(Sheet>>Import>>From Database) where we can establish the connection and fetch the Data from a database table.

Can we acheive this using QTP object Model?

I have the information that data can be fetched from DB in following manner, just wondering if there's a Way to acheive Import Database feature of QTP DataSheet.
----------------------------------------------------------
Code:
set con = CreateObject("adodb.connection")
Set rs = CreateObject("adodb.recordset")
con.Open("Provider=sqloledb.1;Data Source=RAJESHWAR;Initial Catalog=Northwind;User Id='sa';Password='sa'")
rs.Open "select  Top(10) *  from customers",con
DataTable.GlobalSheet.AddParameter "CustomerId",""
DataTable.GlobalSheet.AddParameter "CompanyName",""
DataTable.GlobalSheet.AddParameter "CustomerName",""
i=1
Do while Not rs.EOF
  DataTable.GlobalSheet.SetCurrentRow(i)
  DataTable.Value("CustomerId") =rs.Fields.Item(0)
  DataTable.Value("CompanyName") =rs.Fields.Item(1)
  DataTable.Value("CustomerName") =rs.Fields.Item(2)
  i=i+1
  rs.MoveNext
Loop
con.Close
Reply


Messages In This Thread
Importing Data from a Database - by rajeshwar - 05-26-2010, 12:44 PM
RE: Importing Data from a Database - by Saket - 05-26-2010, 01:03 PM
RE: Importing Data from a Database - by rajeshwar - 05-26-2010, 02:48 PM
RE: Importing Data from a Database - by qtp-qa - 04-03-2012, 12:23 AM
RE: Importing Data from a Database - by lotos - 09-14-2010, 08:45 PM
RE: Importing Data from a Database - by lotos - 11-23-2010, 08:40 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Importing excel not working Adam82 6 13,597 11-05-2012, 05:22 PM
Last Post: Adam82
  it is possible import from excel to table with expected data of checkpoint database i sarcastic 0 2,256 08-05-2011, 04:42 PM
Last Post: sarcastic
Smile importing objects and properties to excel sheet sandy.jakhar 2 3,686 03-16-2011, 03:26 PM
Last Post: sandy.jakhar
  mapping database user to database kamalteja 4 4,686 11-03-2010, 11:58 AM
Last Post: kamalteja
  Data importing from excel using script vaigundamoorthy 3 3,716 05-19-2009, 04:53 PM
Last Post: lit_73

Forum Jump:


Users browsing this thread: 1 Guest(s)