dbTalk Databases Forums  

Export data to Excel using DTS within ASP

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Export data to Excel using DTS within ASP in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
X. Zhang
 
Posts: n/a

Default Export data to Excel using DTS within ASP - 11-26-2004 , 11:05 AM






I tried to export data from SQL Server to a Excel file within ASP. I use
DTSPackage object library V2.0. I know that it can connection to a Excel file
using the following code in VB. But I got problem within ASP. The error shows
up while my ASP running: "Microsoft VBScript rnntiom error: Object doesn't
support this property or method: 'ConnectionProperties' ", which means, I
think, that VBScript does NOT support "ConnectionProperties". How can I
specify my data type to Excel file using VBScript within ASP?

Set oConnection = goPackage.Connections.New("Microsoft.Jet.OLEDB.4.0 ")

oConnection.ConnectionProperties("Data Source") = "C:\My
Documents\tblReportType1.xls"
oConnection.ConnectionProperties("Extended Properties") = "Excel
8.0;HDR=YES;"

oConnection.Name = "Connection 2"
oConnection.ID = 2
oConnection.Reusable = True
oConnection.ConnectImmediate = False
oConnection.DataSource = "C:\My Documents\tblReportType1.xls"
oConnection.UserID = "Admin"
oConnection.ConnectionTimeout = 60
oConnection.UseTrustedConnection = False
oConnection.UseDSL = False

'If you have a password for this connection, please uncomment and add your
password below.
'oConnection.Password = "<put the password here>"

goPackage.Connections.Add oConnection
Set oConnection = Nothing


Reply With Quote
  #2  
Old   
X. Zhang
 
Posts: n/a

Default RE: Export data to Excel using DTS within ASP - 11-26-2004 , 04:11 PM






Problem solved!
In VBScript, you have to user ".ConnectionProperties("Data Source").Value"

"X. Zhang" wrote:

Quote:
I tried to export data from SQL Server to a Excel file within ASP. I use
DTSPackage object library V2.0. I know that it can connection to a Excel file
using the following code in VB. But I got problem within ASP. The error shows
up while my ASP running: "Microsoft VBScript rnntiom error: Object doesn't
support this property or method: 'ConnectionProperties' ", which means, I
think, that VBScript does NOT support "ConnectionProperties". How can I
specify my data type to Excel file using VBScript within ASP?

Set oConnection = goPackage.Connections.New("Microsoft.Jet.OLEDB.4.0 ")

oConnection.ConnectionProperties("Data Source") = "C:\My
Documents\tblReportType1.xls"
oConnection.ConnectionProperties("Extended Properties") = "Excel
8.0;HDR=YES;"

oConnection.Name = "Connection 2"
oConnection.ID = 2
oConnection.Reusable = True
oConnection.ConnectImmediate = False
oConnection.DataSource = "C:\My Documents\tblReportType1.xls"
oConnection.UserID = "Admin"
oConnection.ConnectionTimeout = 60
oConnection.UseTrustedConnection = False
oConnection.UseDSL = False

'If you have a password for this connection, please uncomment and add your
password below.
'oConnection.Password = "<put the password here>"

goPackage.Connections.Add oConnection
Set oConnection = Nothing


Reply With Quote
  #3  
Old   
K. Som
 
Posts: n/a

Default RE: Export data to Excel using DTS within ASP - 11-26-2004 , 07:55 PM



Alternatively, you can include the following

Response.ContentType = "application/vnd.ms-excel"

at the top of your classic asp page.

"X. Zhang" wrote:

Quote:
I tried to export data from SQL Server to a Excel file within ASP. I use
DTSPackage object library V2.0. I know that it can connection to a Excel file
using the following code in VB. But I got problem within ASP. The error shows
up while my ASP running: "Microsoft VBScript rnntiom error: Object doesn't
support this property or method: 'ConnectionProperties' ", which means, I
think, that VBScript does NOT support "ConnectionProperties". How can I
specify my data type to Excel file using VBScript within ASP?

Set oConnection = goPackage.Connections.New("Microsoft.Jet.OLEDB.4.0 ")

oConnection.ConnectionProperties("Data Source") = "C:\My
Documents\tblReportType1.xls"
oConnection.ConnectionProperties("Extended Properties") = "Excel
8.0;HDR=YES;"

oConnection.Name = "Connection 2"
oConnection.ID = 2
oConnection.Reusable = True
oConnection.ConnectImmediate = False
oConnection.DataSource = "C:\My Documents\tblReportType1.xls"
oConnection.UserID = "Admin"
oConnection.ConnectionTimeout = 60
oConnection.UseTrustedConnection = False
oConnection.UseDSL = False

'If you have a password for this connection, please uncomment and add your
password below.
'oConnection.Password = "<put the password here>"

goPackage.Connections.Add oConnection
Set oConnection = Nothing


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.