VB Script to connect to Import the data from Database to Excel
18 Jul 2008 - 10:11:04 am

Dim cnt
Set cnt = CreateObject("ADODB.Connection")
cnt.Provider = "SQLOLEDB"
cnt.ConnectionString= "Driver={SQL Server};Server=127.0.0.1;Database=Northwind;UID=sa;PWD="
cnt.Open
Set recordSet = CreateObject("ADODB.Recordset")
Set recordSet1=cnt.Execute("Select * from Employees")

Set objStream=CreateObject("ADODB.Stream")
 
recordSet1.Save objStream,1
 
 
Set objExcel=CreateObject("Excel.Application")
Set objSheet=CreateObject("Excel.Sheet")
objSheet.Application.visible=true
objSheet.activesheet.cells (1,1).CopyFromRecordset recordSet1
objSheet.Saveas "C:\tests.xls"
objExcel.quit
Set objSheet =Nothing
recordSet1.Close
 

suri · 1285 views · 0 comments

Permanent link to full entry

http://automation-qtp.discussionsblog.com/QTP-b1/VB-Script-to-connect-to-Import-the-data-from-Database-to-Excel-b1-p14.htm

Comments

No Comment for this post yet...


Leave a comment

No comments are allowed in this blog

Last Comment

Yes, Even I agree. Some of ...

2009-12-22 @ 05:59:03 pm
by siva


I agree, some of the answers ...

2009-11-09 @ 03:59:29 pm
by ashwani


Can anyone tell me how to ...

2009-03-01 @ 12:38:47 pm
by harshada


Hi Can anyone help me out ...

2008-11-20 @ 05:01:49 pm
by Ramesh


some of your answers are wrong....

2008-09-15 @ 03:28:25 pm
by avnish


please post HP0-M80 & HP0-M81 Sample ...

2008-08-22 @ 08:46:36 pm
by Test


Hi dhruv, ...

2008-07-28 @ 08:35:15 am
by suri


Hi all,

This blog is ...

2008-07-28 @ 06:47:17 am
by dhruv


hi experts, this is gud site.. from ...

2008-07-22 @ 11:19:25 pm
by rameshtt


Hi , Here I'm giving a ...

2008-07-17 @ 03:59:04 pm
by lavanya


You can do that by using ...

2008-07-17 @ 09:01:26 am
by suri


How to Highlight the textbox data 'To ...

2008-07-17 @ 08:58:30 am
by suri


Please provide answers to these questions

2008-07-16 @ 03:53:48 pm
by Sreekanth


Hi , ...

2008-07-16 @ 12:50:21 pm
by Admin


We can do the same in ...

2008-07-16 @ 12:34:07 pm
by Admin


Who's Online?

Member: 0
Visitor: 1

Announce

Tags

No tags in this Blog

rss Syndication

Archives