Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Exporting MsSQL table to Excel using vbScript?

Reply
 
Old 03-19-2009   #1 (permalink)
StephaneLeFou


 
 

Exporting MsSQL table to Excel using vbScript?

Hi,

I wrote a vbscript application that connects to a remote MsSql
database via ODBC. I can connect, query the db and fetch records
without any problem. However I'd like to export the contents of one
table to an Excel 8.0 file on my local filesystem, just like I do it
in MsAccess, using linked tables.


Syntax #1:

objConnection.execute "insert into OPENROWSET('Microsoft.Jet.OLEDB.
4.0','Excel 8.0;Database=C:\TEST.xls;', 'SELECT * from Sheet1$]')
select * from Computers"

It doesn't work. One error I'm recieving is:

"Ad hoc access to OLE DB provider 'Microsoft.Jet.OLEDB.4.0' has been
denied, You must access this provider through a linded server"

Syntax #2:
objConnection.execute "SELECT * INTO [Excel 8.0;Database=c:\test.xls].
[Sheet1] FROM Computers"

Gives me this error:

"CREATE TABLE permission denied in database 'xyzDatabase".

I know I only have readonly permissions on the DB, but the Excel sheet
I want to create is on my local filesystem.

Any suggestion?
Thanks in advance.


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
vbscript to alter table in msaccess VB Script
Exporting an Excel file Vista General
ways to connect to MSSQL 2000 sever via vbscript VB Script
Exporting to excel PowerShell
dynamic table excel 2007? Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46