I was warking in SSIS 2010 to make transfaring for my project from my pc to the server but i faced a problem with C# Script task it working in my pc very well but in the server it's give me an erro.
This error when i execute the script
and that's the C# Script:
#region Help: Introduction to the script task
#endregion
#region Namespaces
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System;// Basic Import Statement
using System.Collections.Generic; // Allows Us To Use Lists
using System.IO; // For File handles
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
#endregion
namespace ST_c47c0258ca4d4851b04d0fdb997749b9
{
[Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute]
public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
{
#region Help: Using Integration Services variables and parameters in a script
#endregion
#region Help: Firing Integration Services events from a script
#endregion
#region Help: Using Integration Services connection managers in a script
#endregion
public void Main()
{
string inFolderName = @"\\SERVER\DWH File\SocialMedia\Source\Facebook\";
string outFolderName = @"\\SERVER\DWH File\SocialMedia\Final Source\Facebook\";
List<string> lines = new List<string>();
string line;
DirectoryInfo folder = new DirectoryInfo(inFolderName);//Assuming Test is your Folder
FileInfo[] Files = folder.GetFiles("*.csv"); //Getting Text files
using (var file = new System.IO.StreamReader(outFolderName + "Facebook Insights.csv"))
{
while ((line = file.ReadLine()) != null)
{
lines.Add(line);
}
}
foreach (FileInfo f in Files)
{
using (var file = new System.IO.StreamReader(f.FullName))
{
while ((line = file.ReadLine()) != null)
{
if (line.Length == 0 || line.Contains("#") || line.ToLower().Contains("date") || line.ToLower().Contains("screen"))
{
continue;
}
else
{
lines.Add(line);
}
}
//System.IO.File.WriteAllLines(outFolderName + "TwtMentions.csv", lines.ToArray());
}
System.IO.File.WriteAllLines(outFolderName + "Facebook Insights.csv", lines.ToArray());
File.Delete(f.FullName);
}
Dts.TaskResult = (int)ScriptResults.Success;
}
#region ScriptResults declaration
enum ScriptResults
{
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
};
#endregion
}
}
my question where is the problem
I have a feeling it's probably your folder URIs. When a package runs under your user ID, it uses your permissions, but when run from sql agent, you have to make sure it runs under the correct permissions so it will be allowed to access that network location.
See this:
http://bi-polar23.blogspot.com/2007/12/ssis-and-sql-server-agent.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.