|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Yesterday @ 3:49 AM
Points: 146,
Visits: 612
|
|
Using the following code to try and download a file from an http site, but its not working. Need some help/advice please.
' Microsoft SQL Server Integration Services Script Task ' Write scripts using Microsoft Visual Basic ' The ScriptMain class is the entry point of the Script Task.
Imports System Imports System.Data Imports System.Math Imports System.Net Imports Microsoft.SqlServer.Dts.Runtime
<System.AddIn.AddIn("ScriptMain", Version:="1.0", Publisher:="", Description:="")> _ <System.CLSCompliantAttribute(False)> _ Partial Public Class ScriptMain Inherits Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
Enum ScriptResults Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure End Enum
Public Sub Main() Dim wc As WebClient Dim strUrl As String Dim strFilename As String Dim fireAgain As Boolean Try wc = New WebClient() strUrl = "http://nppesdata.cms.hhs.gov/" & Dts.Variables("DownloadFile").Value.ToString() strFilename = "C:\Downloads\NPI\NPPES_Data_Dissemination.zip" 'strFilename = "\\venus\Projects‑Dms\Diamond\Source\02678\SourceData\NPPES_Data_Dissemination.zip("")
wc.DownloadFile(strUrl, strFilename) Dts.TaskResult = ScriptResults.Success Catch ex As Exception Dts.Events.FireError(0, String.Empty, ex.Message, String.Empty, 0)
Dts.TaskResult = ScriptResults.Failure
End Try
End Sub
End Class
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Friday, March 29, 2013 11:17 AM
Points: 3,432,
Visits: 14,332
|
|
strUrl = "http://nppesdata.cms.hhs.gov/" & Dts.Variables("DownloadFile").Value.ToString() strFilename = "C:\Downloads\NPI\NPPES_Data_Dissemination.zip" 'strFilename = "\\venus\Projects‑Dms\Diamond\Source\02678\SourceData\NPPES_Data_Dissemination.zip("")
The account used to connect to SSIS and the Asp.net runtime must have permission in the above directory for your code to run. Check below for the default Asp.net permission.
http://msdn.microsoft.com/en-us/library/kwzs111e.aspx
Kind regards, Gift Peddie
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Yesterday @ 3:49 AM
Points: 146,
Visits: 612
|
|
| I'm just running on my local machine for development purposes and saving locallyso I don't think its a permissions thing.
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Friday, March 29, 2013 11:17 AM
Points: 3,432,
Visits: 14,332
|
|
tan110 (1/12/2010) I'm just running on my local machine for development purposes and saving locallyso I don't think its a permissions thing.
So you are saying when you are running code locally runtime file permission is not needed, run the CLR debugger it is very good in showing Asp.net permissions issues.
Kind regards, Gift Peddie
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Yesterday @ 3:49 AM
Points: 146,
Visits: 612
|
|
This is the error I get when trying to run/debug it:
An error occured while compiling the script for the Script task.
Poject name: ScriptTask_5c78af1250a74913a5bc7015b74ecf16
Error 30002: Type 'System.AddIn.AddIn' is not defined. Line 12 Column 2 through 19
<System.AddIn.AddIn("ScriptMain", Version:="1.0", Publisher:="", Description:="")> _
Thanks again.
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Friday, March 29, 2013 11:17 AM
Points: 3,432,
Visits: 14,332
|
|
tan110 (1/12/2010) This is the error I get when trying to run/debug it:
An error occured while compiling the script for the Script task.
Poject name: ScriptTask_5c78af1250a74913a5bc7015b74ecf16
Error 30002: Type 'System.AddIn.AddIn' is not defined. Line 12 Column 2 through 19
<System.AddIn.AddIn("ScriptMain", Version:="1.0", Publisher:="", Description:="")> _
Thanks again.
What is the reason system.addin is not in your import statements but I still think you will still have to handle the file permission.
Kind regards, Gift Peddie
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Yesterday @ 3:49 AM
Points: 146,
Visits: 612
|
|
I went ahead and added it in the Import stmt, but still recieving the same error. Can run this successfully on your machine?
Thanks.
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Friday, March 29, 2013 11:17 AM
Points: 3,432,
Visits: 14,332
|
|
tan110 (1/12/2010) I went ahead and added it in the Import stmt, but still recieving the same error. Can run this successfully on your machine?
Thanks.
I am not aware you can access the c drive in code without system.io so you need to debug and fix your code.
Kind regards, Gift Peddie
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Yesterday @ 3:49 AM
Points: 146,
Visits: 612
|
|
| I'm stuck on this one. Don't know what to do to fix the code. Again I appreciate you posting your comments.
|
|
|
|