Ejecutar DTS en el servidor...

15/10/2003 - 11:57 por cArLeS!! | Informe spam
Hola.

Tengo un DTS que contiene sólo un ActiveX Task con un
pequeño trozo de codigo VB-Script que abre un archivo
Excel, ejecuta una macro dentro de este y luego lo guarda
con otro nombre. Esto se hace de forma recursiva.

El problema es que cuando ejecuto este DTS directamente
(desde el Enterprise Manager, directamente sobre el
servidor) todo funciona ok. Pero cuando desde un cliente
lo ejecuto mediante el comando xp_cmdshell se queda
colgado (no hace nada, y al parecer el cuelgue se produce
al hacer SaveAs).

Alguien me puede ayudar?

El codigo del script es el siguiente:

'**********************************************************
************
' Visual Basic ActiveX Script
'**********************************************************
**************
'// Global variables
Dim oConn
Dim oRS_Data
Dim oRS_Data2

Function Main()

Dim app
Dim book

' open connection
Set oConn = CreateObject("ADODB.Connection")
With oConn
.Provider = "SQLOLEDB.1"
.Properties("Data Source").Value = "DWH-BCN"
.Properties("Initial Catalog").Value = "MSA"
.Properties("Integrated Security").Value = "SSPI"
.Open
End With


' open main recordset
Set oRS_Data = CreateObject("ADODB.Recordset")

oRS_Data.Open "SELECT * FROM [X_SBPRocess_SalesRep] ",
oConn,,2

oConn.Execute "TRUNCATE TABLE log "

set app = CreateObject("Excel.Application")
app.DisplayAlerts = False 'by CESCOLA

While Not oRS_Data.EOF
if oRS_Data(0) <> "" then
Set book = app.workbooks.Open
("X:\Reporting\SalesBudgetTemplateV001.01.xls")

oConn.Execute "INSERT INTO log (logmsg)
VALUES ('" & oRS_Data(0) & "')"

app.Run "SalesBudgetTemplateV001.01.xls!
RefreshData", DTSGlobalVariables("Year").Value, oRS_Data
(0), "DWH-BCN"

book.SaveAs DTSGlobalVariables("Path").Value
& "Template " & trim(oRS_Data(0))

book.Close
Set book = Nothing

end if
oRS_Data.movenext
Wend

app.DisplayAlerts = True 'by CESCOLA
app.Quit
Set app = Nothing

Main = DTSTaskExecResult_Success
End Function
 

Leer las respuestas

#1 Javier Loria
15/10/2003 - 15:14 | Informe spam
Hola cArLeS:
Me parece que el problema puede estar en el uso de la ruta
"X:\Reporting\...", ya que asumo que el servidor no tiene un dispositivo X,
sino mas bien que es un MAP a algun directorio compartido. Podrias cambiar
el texto por: \\Servidor\CarpetaCompartida\Reporting..., para ver si
funciona?

Saludos,


Javier Loria
Costa Rica
Se aprecia la inclusion de DDL (CREATE, INSERTS, etc.)
que pueda ser copiado y pegado al Query Analizer.
La version de SQL y Service Pack tambien ayuda.
cArLeS!! escribio:
Hola.

Tengo un DTS que contiene sólo un ActiveX Task con un
pequeño trozo de codigo VB-Script que abre un archivo
Excel, ejecuta una macro dentro de este y luego lo guarda
con otro nombre. Esto se hace de forma recursiva.

El problema es que cuando ejecuto este DTS directamente
(desde el Enterprise Manager, directamente sobre el
servidor) todo funciona ok. Pero cuando desde un cliente
lo ejecuto mediante el comando xp_cmdshell se queda
colgado (no hace nada, y al parecer el cuelgue se produce
al hacer SaveAs).

Alguien me puede ayudar?

El codigo del script es el siguiente:

'**********************************************************
************
' Visual Basic ActiveX Script
'**********************************************************
**************
'// Global variables
Dim oConn
Dim oRS_Data
Dim oRS_Data2

Function Main()

Dim app
Dim book

' open connection
Set oConn = CreateObject("ADODB.Connection")
With oConn
.Provider = "SQLOLEDB.1"
.Properties("Data Source").Value = "DWH-BCN"
.Properties("Initial Catalog").Value = "MSA"
.Properties("Integrated Security").Value = "SSPI"
.Open
End With


' open main recordset
Set oRS_Data = CreateObject("ADODB.Recordset")

oRS_Data.Open "SELECT * FROM [X_SBPRocess_SalesRep] ",
oConn,,2

oConn.Execute "TRUNCATE TABLE log "

set app = CreateObject("Excel.Application")
app.DisplayAlerts = False 'by CESCOLA

While Not oRS_Data.EOF
if oRS_Data(0) <> "" then
Set book = app.workbooks.Open
("X:\Reporting\SalesBudgetTemplateV001.01.xls")

oConn.Execute "INSERT INTO log (logmsg)
VALUES ('" & oRS_Data(0) & "')"

app.Run "SalesBudgetTemplateV001.01.xls!
RefreshData", DTSGlobalVariables("Year").Value, oRS_Data
(0), "DWH-BCN"

book.SaveAs DTSGlobalVariables("Path").Value
& "Template " & trim(oRS_Data(0))

book.Close
Set book = Nothing

end if
oRS_Data.movenext
Wend

app.DisplayAlerts = True 'by CESCOLA
app.Quit
Set app = Nothing

Main = DTSTaskExecResult_Success
End Function

Preguntas similares