Prepare for your Next Interview
|
Welcome to the Geeks Talk forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
This is a discussion on How to Import the data from MS-Access in QTP? within the QTP forums, part of the Software Testing category; Hi, Any one tell me How to Import the data from MS-Access in QTP?...
|
|||||||
|
|||
|
How to Import the data from MS-Access in QTP?
Hi,
Any one tell me How to Import the data from MS-Access in QTP? |
| The Following User Says Thank You to ramyamca1984 For This Useful Post: | ||
| Sponsored Links |
|
|||
|
Hi Ramya,
You can use the same createObject method to export data from MS Access as well. Here is the code guideline for the following - dim oConn dim sRec set oConn = createObject("ADODB.Connection") oConn.open "Provider = Microsoft.Jet.OLEDB.4.0;DataSource = < NOTE : Incase authentication is required as in case of SQL Server, we would have to pass UserID and Pwd as well. set sRec = createObject("ADODB.Recordset") sRec.open "Select * from where .... conditions", oConn, adLockOptimistic, adOpenDynamic for i = 0 to rs.EOF ar[i] = sRec.fields(i) next NOTE : Incase rs.EOF does not work, try the following code - dim item For each item in sRec.fields Next sRec.MoveNext Cheers......
__________________
Regards, V.Umesh Krishnan QA Consultant |
|
|||
|
Re: How to Import the data from MS-Access in QTP?
Hi ramya, here you can use this code for getting data from database by using msaccess..
''''''''''''''To Retrieve the Data From Database'''''''''''''''''''''''''''''''''''''''''''''''''''' '''''To retrieve the data from two tables'''''''''''''''''''''''''''' Dim Dsn_conn,rs Set objConnection=Createobject("ADODB.Connection")'Create connection object with DSN Dsn_conn= "DSN=QT_Flight32;DBQ=C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight32.mdb;Driver=C:\WINNT\system32\odbcjt32.dll;DriverId=281;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;" objConnection.Open(Dsn_conn)'Open the connection Set rs=CreateObject("ADODB.RecordSet") 'Create recordset object Set rs=objconnection.execute("select Orders.Customer_Name,Flights.Departure from Orders,Flights where Orders.Flight_Number=Flights.Flight_Number") rs.MoveFirst row=1 datatable.GetSheet(1).addparameter"Customer_Name","" datatable.GetSheet(1).addparameter"Departure","" While Not rs.EOF ONumber=rs.fields.item("Customer_Name") CName=rs.fields.item("Departure") datatable.SetCurrentRow(row) datatable.Value (1,1)=ONumber datatable.Value(2,1)=CName row=row+1 rs.movenext Wend objConnection.Close _________________________ Thanks & Regards Arun Singh Rajaputra Last edited by rajaputra; 03-20-2008 at 01:07 PM. |
|
|||
|
Re: How to Import the data from MS-Access in QTP?
Hi Ramya,
Here you can use this code for getting data from database by using msaccess.. ''''''''''''''To Retrieve the Data From Database'''''''''''''''''''''''''''''''''''''''''''''''''''' '''''To retrieve the data from two tables'''''''''''''''''''''''''''' Dim Dsn_conn,rs Set objConnection=Createobject("ADODB.Connection")'Create connection object with DSN Dsn_conn= "DSN=QT_Flight32;DBQ=C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight32.mdb;Driver=C:\WINNT\system32\odbcjt32.dll;DriverId=281;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;" objConnection.Open(Dsn_conn)'Open the connection Set rs=CreateObject("ADODB.RecordSet") 'Create recordset object Set rs=objconnection.execute("select Orders.Customer_Name,Flights.Departure from Orders,Flights where Orders.Flight_Number=Flights.Flight_Number") rs.MoveFirst row=1 datatable.GetSheet(1).addparameter"Customer_Name","" datatable.GetSheet(1).addparameter"Departure","" While Not rs.EOF ONumber=rs.fields.item("Customer_Name") CName=rs.fields.item("Departure") datatable.SetCurrentRow(row) datatable.Value (1,1)=ONumber datatable.Value(2,1)=CName row=row+1 rs.movenext Wend objConnection.Close _____________________ Thanks & Regards Arunsingh Rajaputra |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Unable to import data into local sheet | Geek_Guest | QTP | 4 | 05-27-2009 02:19 AM |
| How to Import the data from MS-Excel in QTP? | ramyamca1984 | QTP | 11 | 03-23-2009 12:58 PM |
| access outside data from iframe... | psuresh1982 | Web Design | 0 | 07-31-2007 05:11 AM |
| Data Access Layer For Microsoft Access | Lokesh M | VB.NET | 0 | 12-02-2006 11:35 AM |
| Microsoft CRM : 5 ways to import data | Jim.Anderson | Microsoft CRM | 0 | 09-27-2006 07:39 AM |