Script Task output in Chinese???
I added some error logging to my package and now my script task output looks like Chinese. This is not the error file I set up for the error logging but another text file that I was sending
results too. Next I took out the logging stuff and it still was not working right. So… I created a new project and imported my package into that and it is still spitting out what looks like Chinese. I looked at all the properties on each
task and verified that the LocaleID is set to English (United States). When I delete the text file I am send my data too and have it create while the package runs it comes out in English. It seems to work ok now but I am wondering why that
happened in the first place and if this is something that will happen again when in production. What I can do to prevent it from happening again.
tks!
Reach for the unknown!
1st time I see this happening, I think there is no need to panic.
The code page/encoding chosen for the log file was incorrect looks like. And perhaps this is due to the the computer locale being temporary incorrect (or still not).
Arthur
MyBlog
Twitter
Similar Messages
-
Script task to convert output from a sql query into send mail task body formatting
SSIS 2008R2 Version
Code from script task
Microsoft SQL Server Integration Services Script Task
Write scripts using Microsoft Visual C# 2008.
The ScriptMain is the entry point class of the script.
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
namespace ST_29dd6843bd6c4aee9b1656c1bbf55ba8.csproj
[System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
#region VSTA generated code
enum ScriptResults
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
#endregion
public void Main()
Variables varCollection = null;
string header = string.Empty;
string message = string.Empty;
Dts.VariableDispenser.LockForWrite("User::gsEmailMessage");
Dts.VariableDispenser.LockForWrite("User::gsWebserviceName");
Dts.VariableDispenser.LockForWrite("User::gsNoOfCallsInADay");
Dts.VariableDispenser.LockForWrite("User::gsCalledBySystem");
Dts.VariableDispenser.GetVariables(ref varCollection);
//Set the header message for the query result
if (varCollection["User::gsEmailMessage"].Value == string.Empty)
header = "Hi, Count is greater then 50 :\n\n";
//header = "Execute SQL task output sent using Send Email Task in SSIS:\n\n\n";
header += "----------------------------------------------------------------------------------------------------------------------" + "\n";
header += string.Format("{0}\t\t\t\t{1}\t\t{2}\n", "WebService Name", "No Of Calls In A Day", "Called By System");
header += "----------------------------------------------------------------------------------------------------------------------" + "\n";
varCollection["User::gsEmailMessage"].Value = header;
//Format the query result with tab delimiters
message = String.Format("<HTML><BODY><P>{0}</P><P>{1}</P><P>{2}</P></BODY></HTML>",
varCollection["User::gsWebserviceName"].Value,
varCollection["User::gsNoOfCallsInADay"].Value,
varCollection["User::gsCalledBySystem"].Value);
varCollection["User::gsEmailMessage"].Value = varCollection["User::gsEmailMessage"].Value + message + "\n";
Dts.TaskResult = (int)ScriptResults.Success;
Above code will return data in below format and then i send this output in aemail using send mail task.
Hi, count is greater then 50 :
WebService Name
No Of Calls In A Day Called By System
WebServiceone 1
Internetbutiken
WebServiceGetdetailstwo 1
Internetbutiken
Servicenamethree 2
MOB
As you can see above code is not in align as if we service name is shorter then 2nd column get disallign and its not look good.I need output should be like below.
Hi, count is greater then 50 :
WebService Name
No Of Calls In A Day Called By System
WebServiceone 1
Internetbutiken
WebServiceGetdetailstwo 1
Internetbutiken
Servicenamethree 2
MOB
Please suggest something...
Thanks
SR_MCTSSee code explained here
http://microsoft-ssis.blogspot.in/2013/08/sending-mail-within-ssis-part-2-script.html
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs
This will not help.As I am not creating smtp connectin ,send from ,send to in script task.I am just creating email body from sql output. -
Output from script task to cmd prompt
Hi,
I have a SISS package that has script task in it.
I'm exeuting the package in the command prompt using the following command.
DTEXEC.EXE /F "C:\Documents and Settings\Devuser\Desktop\Deployment\Package.dtsx" /set \package.variables[filepath].Value;"C:\\Documents and Settings\\Devuser\\Desktop\\Release-Deployment\\release\\"
It is sucessfully executed and the following is displayed in the command prompt screen.
DTExec : The package execution returned DTDER_SUCESS <0>
However, i would like to show cusom message. Is it possible to show custom message string returned by the script task?
Please assist me.
Thanks,
Venkat.
Best Regards, VenkatNo, I haven't tried events.
Could you please point me some tutorials or urls where i can get information?
Thanks,
Venkat.
Best Regards, Venkat
Click on the
link in the previous reply. With for example Dts.Events.FireWarning(.......) you can create a warning with a custom text in it.
Please mark the post as answered if it answers your question | My SSIS Blog:
http://microsoft-ssis.blogspot.com |
Twitter -
Script task error during the creation of partition by reading a table and using AMO - SSAS 2012
Hi,
I need to create SSAS (tabular) and process partitions in an authomatic manner. Moreover, the partitioning is respect to a category, an year and a month.
Category, year and month are resident on a table to read to create the SSAS partitions.
So, in a SSIS pkg:
a. I've created a data flow task to read the SQL Server table having category, year and month data,
b. I've connected the output of the ole db source as the input for a recordset destination, associated to an object variable,
c. I've used a for each loop container (ado enumerator) specifying the object variable and three variables, for category, year and month,
d. inside the for each loop container I've created a script task using AMO (visual basic) to control for any existing partitions, if not presents to create the new ones and then to process them.
For the first iteration, a new partition has been created and processed successfully, but then, for other category, year and month values the script task fails. I've controlled the code many times and I've tried to put returning messageboxes but I've found
anything. The error is a generic one and no other info are returned.
Well, any suggests to me in order to solve this issue, please?
Many thanksHi, thanks, I've solved adding to the code end the SSAS server connection termination.
Bye -
SSIS PACKAGE MIGRATION FROM 2005 to 2008 - Script task/component errors
HI All,
We have to migrate ssis packages (about 300) from ssis 2005 to 2008 .
1. I understand that the major concern is regarding the script component/tasks.
I searched a lot about this and also consulted with many friends , all of them are aware of this issue but not able to provide what could be the issues and the solution.
Can some one help me with the common script issues that can happen during migration and the solution for the same.
2. I do have one more question.
As per my understanding given in the below link
http://blogs.msdn.com/b/mattm/archive/2008/03/21/package-upgrade-wizard.aspx
there is this part which says ...
Once the packages have been chosen, the next page asks you to pick the output location. This can be:
Same as the source location
File System
SSIS Service (Package Store)
SQL Server
Does this mean I can deploy in sql server directly on fly while upgrading ?
Any help highly appreciated .
Regards
Praveen..Hi Praveen,
Question 1: The error may occur if there are duplicate input columns in the Script Task/Component or the current user cannot access the C:\Windows\Temp directory. Except for the link provided by SanBhaumik, you can also refer to the following
threads:
http://www.sqlservercentral.com/Forums/Topic811208-148-1.aspx
http://social.technet.microsoft.com/Forums/sqlserver/en-US/5c11eb57-59d6-4f81-bfdc-13bd6489a0ac/sql-server-2008-ssis-package-script-component-error?forum=sqlintegrationservices
Question 2: We can directly save the package to the File System, SSIS Package Store, or SQL Server by selecting the proper destination during the package upgrade. However, this operation is not equal to the package install operation identically.
For example, if we have enabled package configurations for a package, the package configurations won’t be upgraded or installed during the package upgrade.
Regards,
Mike Yin
TechNet Community Support -
Calling a restful web service from a script task
Hi. I'm weak in c# but am looking to accomplish this...
I want to call a RESTful web service from an ssis script task. I don't want to create a web service so I'm hoping there is some publicly available one I can practice with before our web team provides me with the service I'll eventually use. Can
the community provide an example? I wish I had more but my knowledge is very limited except for using ssis in more sql centric apps. It would be great if I could exercise both a get and put verb but I understand i'll be lucky if I can even get
a get to work.
Here is an example of a get I found on the web but I don't know if its a viable candidate for me to practice with from my package...
using System;
using System.IO;
using System.Net;
using System.Text;
// Create the web request
HttpWebRequest request = WebRequest.Create("http://developer.yahoo.com/") as HttpWebRequest;
// Get response
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
// Get the response stream
StreamReader reader = new StreamReader(response.GetResponseStream());
// Console application output
Console.WriteLine(reader.ReadToEnd());
and in the same article an example of a put ...
// We use the HttpUtility class from the System.Web namespace
using System.Web;
Uri address = new Uri("http://api.search.yahoo.com/ContentAnalysisService/V1/termExtraction");
// Create the web request
HttpWebRequest request = WebRequest.Create(address) as HttpWebRequest;
// Set type to POST
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
// Create the data we want to send
string appId = "YahooDemo";
string context = "Italian sculptors and painters of the renaissance"
+ "favored the Virgin Mary for inspiration";
string query = "madonna";
StringBuilder data = new StringBuilder();
data.Append("appid=" + HttpUtility.UrlEncode(appId));
data.Append("&context=" + HttpUtility.UrlEncode(context));
data.Append("&query=" + HttpUtility.UrlEncode(query));
// Create a byte array of the data we want to send
byte[] byteData = UTF8Encoding.UTF8.GetBytes(data.ToString());
// Set the content length in the request headers
request.ContentLength = byteData.Length;
// Write data
using (Stream postStream = request.GetRequestStream())
postStream.Write(byteData, 0, byteData.Length);
// Get response
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
// Get the response stream
StreamReader reader = new StreamReader(response.GetResponseStream());
// Console application output
Console.WriteLine(reader.ReadToEnd());
Hi
db042190,
These kinds of operations are commonly found outside the SSIS section of the forum, you just need to "borrow" the code and wrap into the Script Task. And based on what you see you are on the right tracks.
One thing you need to be aware of: in production such RESTfull call usually lead to a fiasco for the machine residing in some kind of DMZ or Firewall rules prohibiting these methods or you need a proxy account to run the package and you face unbeggable admins
who resist to relaxing security.
My suggestion is to go the easy route: write the app up as a console, standalone app - it will be easier to debug and there will be complete examples of them in abundance on the web.
Arthur
MyBlog
Twitter -
Script task how to add date value
hi
i have following code i am trying to add date into script task
Public Overrides Sub CreateNewOutputRows()
Dim vars As IDTSVariables100
Dim vars1 As IDTSVariable100
Dim recordCount As Integer
Dim rdate As Date
' Dim recount As Integer
' Dim rcount As Integer = 0
'Get the record count
Me.VariableDispenser.LockOneForRead("RecordCount", vars)
recordCount = CType(vars("RecordCount").Value, Integer)
' rdate = CType(vars("CurentDate").Value, Date)
vars.Unlock()
Me.VariableDispenser.LockOneForRead("CurrentDate", vars)
rdate = CType(vars("CurrrentDate").Value, Date)
' rdate = CType(vars("CurentDate").Value, Date)
vars.Unlock()
'Me.VariableDispenser.LockOneForRead("rcount", vars)
'rcount = CType(vars("rcount").Value, Integer)
'vars.Unlock()
' rcount = rcount + 1
'Output one row with record count
Output0Buffer.AddRow()
Output0Buffer.FooterRow = String.Format("ABC" & recordCount & rdate)
Output0Buffer.SetEndOfRowset()
in SSIS i have declare CurrentDate in datetime and i need to use it here , but i am getting error.
how to append its value to Output0Buffer.FooterRow = String.Format("ABC" & recordCount & rdate)
its in vb ,i dotn know anything about VB ,please help me.
i havent put anything in readonly,readwrite in script task.ecordCount is working but i did same for rdate and its not workinghow to get that value in yyyymmddhhmmss format in ssis.
whats expression i need to use.
also how to give single space here between recordcount and variables.rdate
Output0Buffer.FooterRow = String.Format("ABC" & recordCount & Variables.rdate) -
Script task within child package - breakpoint wont hit, trying to find missing variable
Im calling a child package and its failing on a script task with a message which indicates one of the variables cant be found
The script threw an exception: The element cannot be found in a collection.
So I remove the readonly/readwrite section, and place a breakpoint on the very first line of the script task. When I run the main package, by breakpoint on the child package script task isnt hit but I still get the error about the missing variable.
How can I find out which variable its complaining about?You can raise an event in the script using FireInformation and pass into it the variable content as string
examples:
http://technet.microsoft.com/en-us/library/ms136054.aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-1
The variable content will put into the Output window (go to View menu to enable it).
Arthur My Blog -
Web Reference inside Script Task causes Binary code for script not found error
I am attempting to access a SOAP web API (sales force) from a SSIS package. To do this I created a script task.
Inside the script task I went to Add Service Reference. Then I click advanced to make it a web reference. Then I point it to the WSDL file and give it a name SFEnterprise. It successfully finds and adds the Web Reference to the script task.
I leave scriptMain.cs alone and I have no warnrings and no errors. Now in the solution explorer I right-click the script task and hit BUILD. I see the message from Output that BUILD succeeded.
I close the VSTA script editor and now I am back on the control flow window. However I have a red X on the script task with the following message. "The Binary code for the script is not found. Please open the script in the designer by clicking EditScript
button and make sure it builds successfully"
But it does build successfully! And I have not even added any custom code except for the web reference using the WSDL file.
I am using SSIS 2012 and Visual Studio 2012. I have been reading about this binary code error message on Google searches and suggestions about delay validation and turning off pre-compile do not apply to SSIS 2012.
Is SSIS not capable of doing this?I was wanting to use the 2.0 coding style of accessing the soap service which is supported by adding the web reference vs. adding a service reference. But using a service reference instead of web reference actually allows the script task to compile. This
is really odd behavior. I wonder why one works and not the other.
Changing my C# code over to service reference coding style to access the SOAP service was still returning an error. When I added a break point I found the error message "Could not find default endpoint element that references contract in the ServiceModel
client configuration section"when calling new SoapClient();
I found this page http://www.sqlis.com/sqlis/post/Where-is-my-appconfig-for-SSIS.aspx and after I copied the System.ServiceModel app settings from the script task app.config to the DTSDebugHost.exe.config it was able to successfully login to the endpoint
during package debug mode.
This means I will have to edit the SQL Server DTS config files on the prod SSIS server to get the package to actually run in the job agent.
So for now I am good I think just plugging away at coding what the script task is actually supposed to do now that is can actually login. -
Error While executing a SSIS package which contains a script task through SQL Server Agent job
Hi,
I have a SQL Server 2012 SSIS package with a script task along with other tasks [data flow, execute sql tasks ]. When I manually executed the job through BIDS, its completed successfully.
Then I have automated the execution of the package through SQL Server Agent Job. But when I executed the package through SQL Agent job, it runs successfully for all the tasks except script task. When it comes to execute the Script Task, it is getting failed
with the below error message.
"Error: 2012-08-29 12:45:14.67
Code: 0x00000001
Source: Script Task
Description: Exception has been thrown by the target of an invocation.
End Error
DTExec: The package execution returned DTSER_FAILURE (1).
Started: 12:45:10 PM
Finished: 12:45:14 PM
Elapsed: 4.353 seconds
I have installed the SSIS on the 64-bit environment and SSIS service is running. Also I tried to run the job through 32 bit [job option] but I am getting the above error in all cases.
Any help will be greatly appreaciated !
Thanks,
Navin
- naveen.reddyHi Arthur,
My script task access the excel files in a network share, refresh them all and save them. When I execute the ETL manually or thru DTEXEC, it is executing successfully. I am facing the issue when I am executing thru SQL Agent Job only. Logging also showing
the same error.
"Error: 2012-08-23 12:45:14.67
Code: 0x00000001
Source: Script Task
Description: Exception has been thrown by the target of an invocation.
End Error
DTExec: The package execution returned DTSER_FAILURE (1).
Started: 12:45:10 PM
Finished: 12:45:14 PM
Elapsed: 4.353 seconds
- naveen.reddy -
Script task fails to send mail to GMAIL
Hi guys ,
I am new here and i am glad i that i am here. I am working in a company as SQL Server developer(T-sql), i am learning SSIS because i wanted to move to data warehousing.
I not familiar and i don't know any thing about C#, but i am learning SSIS on my own.
I tried to send mail to gmail using script task , both sender and receiver with same mail ID using variables which i tried using tutorial i found from the below link.
[quote]http://www.codeproject.com/Articles/85172/Send-Email-from-SSIS-with-option-to-indicate-Email[/quote]
but finally when i execute the task , it returns failure message and email is not sent.
[quote]SSIS package "Send mail using script task.dtsx" starting.
Error: 0x8 at Script Task: The script returned a failure result.
Task failed: Script Task
SSIS package "Send mail using script task.dtsx" finished: Success.
[/quote]
Below message taken from progress tab
[quote]Error: The script returned a failure result.[/quote]
Can you all please help me in finding where i am going wrong? please check below code which i have used in script task.
Microsoft SQL Server Integration Services Script Task
Write scripts using Microsoft Visual C# 2008.
The ScriptMain is the entry point class of the script.
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using System.Net.Mail;
namespace ST_9bc84810a62a401aa44ddd905bcd369d.csproj
[System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
#region VSTA generated code
enum ScriptResults
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
#endregion
The execution engine calls this method when the task executes.
To access the object model, use the Dts property. Connections, variables, events,
and logging features are available as members of the Dts property as shown in the following examples.
To reference a variable, call Dts.Variables["MyCaseSensitiveVariableName"].Value;
To post a log entry, call Dts.Log("This is my log text", 999, null);
To fire an event, call Dts.Events.FireInformation(99, "test", "hit the help message", "", 0, true);
To use the connections collection use something like the following:
ConnectionManager cm = Dts.Connections.Add("OLEDB");
cm.ConnectionString = "Data Source=localhost;Initial Catalog=AdventureWorks;Provider=SQLNCLI10;Integrated Security=SSPI;Auto Translate=False;";
Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.
To open Help, press F1.
public void Main()
string sSubject = "Test Subject";
string sBody = "Test Message";
int iPriority = 2;
if (SendMail(sSubject, sBody, iPriority))
Dts.TaskResult = (int)ScriptResults.Success;
else
//Fails the Task
Dts.TaskResult = (int)ScriptResults.Failure;
public bool SendMail(string sSubject, string sMessage, int iPriority)
try
string sEmailServer = Dts.Variables["sEmailServer"].Value.ToString();
string sEmailPort = Dts.Variables["sEmailPort"].Value.ToString();
string sEmailUser = Dts.Variables["sEmailUser"].Value.ToString();
string sEmailPassword = Dts.Variables["sEmailPassword"].Value.ToString();
string sEmailSendTo = Dts.Variables["sEmailSendTo"].Value.ToString();
string sEmailSendCC = Dts.Variables["sEmailSendCC"].Value.ToString();
string sEmailSendFrom = Dts.Variables["sEmailSendFrom"].Value.ToString();
string sEmailSendFromName = Dts.Variables["sEmailSendFromName"].Value.ToString();
SmtpClient smtpClient = new SmtpClient();
MailMessage message = new MailMessage();
MailAddress fromAddress = new MailAddress(sEmailSendFrom, sEmailSendFromName);
//You can have multiple emails separated by ;
string[] sEmailTo = Regex.Split(sEmailSendTo, ";");
string[] sEmailCC = Regex.Split(sEmailSendCC, ";");
int sEmailServerSMTP = int.Parse(sEmailPort);
smtpClient.Host = sEmailServer;
smtpClient.Port = sEmailServerSMTP;
System.Net.NetworkCredential myCredentials =
new System.Net.NetworkCredential(sEmailUser, sEmailPassword);
smtpClient.Credentials = myCredentials;
message.From = fromAddress;
if (sEmailTo != null)
for (int i = 0; i < sEmailTo.Length; ++i)
if (sEmailTo[i] != null && sEmailTo[i] != "")
message.To.Add(sEmailTo[i]);
if (sEmailCC != null)
for (int i = 0; i < sEmailCC.Length; ++i)
if (sEmailCC[i] != null && sEmailCC[i] != "")
message.To.Add(sEmailCC[i]);
switch (iPriority)
case 1:
message.Priority = MailPriority.High;
break;
case 3:
message.Priority = MailPriority.Low;
break;
default:
message.Priority = MailPriority.Normal;
break;
//You can enable this for Attachments.
//SingleFile is a string variable for the file path.
//foreach (string SingleFile in myFiles)
// Attachment myAttachment = new Attachment(SingleFile);
// message.Attachments.Add(myAttachment);
message.Subject = sSubject;
message.IsBodyHtml = true;
message.Body = sMessage;
smtpClient.Send(message);
return true;
catch (Exception ex)
return false;
Please help me resolve this guys ... THANKS IN ADVANCEThank you very much for your reply @Elvis Long,
Sorry for the late reply
Actually, i am not trying or executing this task from my office , but i am trying this at my home :( .
sEmailPort has value 587 sEmailServer has smtp.gmail.com
Can you please check whether this C# coding is correct or not ? because finally it gives error saying "Script
Task: The script returned a failure result"
so can you please check this with your system and let me know what is wrong with this code
Thanks in advance -
Getting error message when i am trying to update the excel file using script task in ssis package
Hi Guys,
I am getting error message when I am trying to update the excel. Please find the error messages as below
Error at Update File [Update File]: Failed to compiled scripts contained in the package. Open the package in SSIS Designer and resolve the compilation errors.
Error at Update File [Update File]: BC30002 - Type 'Microsoft.Office.Interop.Excel.Application' is not defined., ScriptMain.vb, 32, 32
Error at Update File [Update File]: BC30002 - Type 'Microsoft.Office.Interop.Excel.Workbook' is not defined., ScriptMain.vb, 33, 25
Error at Update File [Update File]: The binary code for the script is not found. Please open the script in the designer by clicking Edit Script button and make sure it builds successfully.
Warning at Update File [Update File]: Found SQL Server Integration Services 2008 Script Task "ST_050fcae972904039b4f0fe59b7528ece" that requires migration!
and the code that I am using is
Dell - Internal Use - Confidential
' 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 Microsoft.SqlServer.Dts.Runtime
Imports Microsoft.Office.Interop.Excel
<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()
Dts.TaskResult = ScriptResults.Success
'Dim proc As System.Diagnostics.Process
'kill all instances of excel
'For Each proc In System.Diagnostics.Process.GetProcessesByName("EXCEL")
' proc.Kill()
'Next
Dim excelnacomm As
New Microsoft.Office.Interop.Excel.Application
Dim wbnacomm As Microsoft.Office.Interop.Excel.Workbook
wbnacomm = excelnacomm.Workbooks.Open("http://test.xlsx")(renamed
the excel)
wbnacomm.RefreshAll()
wbnacomm.Save()
wbnacomm.Close()
excelnacomm.Quit()
Runtime.InteropServices.Marshal.ReleaseComObject(excelnacomm)
End Sub
End
Class
Please let me know what could be the reason
Smash126Download:
Microsoft Office 2010: Primary Interop Assemblies Redistributable
How to: Add or Remove References By Using the Add Reference Dialog Box / How to:
Add and Remove References in Visual Studio (C#)
Olaf Helper
[ Blog] [ Xing] [ MVP] -
SSIS/Script Task/ VB 2008 Help Urgent...
Hi Guys,
Simple Script Task, just rename Excel tab, here is my code...
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Imports Microsoft.Office.Interop.Excel
Imports System.IO
Imports System.Text
<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()
Dts.VariableDispenser.LockForRead("User::FileName") ' File Name Variable
Dim variablesList As Variables
Dts.VariableDispenser.GetVariables(variablesList)
'Dim SFileName As String
'SFileName = variablesList("User::Filename").Value.ToString
' Dim vars As Variables 'New Added For Variable
Dim oMissing As Object = System.Reflection.Missing.Value
Dim xl As New Microsoft.Office.Interop.Excel.ApplicationClass()
Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet
'Dts.VariableDispenser.LockForRead("Filename") 'New Added For Variable
'Start For Variable
'Dim File As String 'New Added For Variable
'File = CType(vars("Filename").Value, String) 'New Added For Variable
'MsgBox(Prompt:="Filename")
'Dim laPath As String = "C:\Excel\ABC_dr_daily_lf_10-07-14.xls" 'My File Name
Dim lapath As String = variablesList("User::FileName").Value.ToString 'New Added For Variable
'MsgBox(Prompt:="Filename")
xlBook = DirectCast(xl.Workbooks.Open(laPath, oMissing, oMissing, oMissing, oMissing, oMissing, _
oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, _
oMissing, oMissing, oMissing), Workbook)
xlSheet = DirectCast(xlBook.Worksheets.Item(1), Worksheet)
xlSheet.Name = "data"
xlBook.Save()
xl.Application.Workbooks.Close()
Dts.TaskResult = ScriptResults.Success
End Sub
End Class
Finally I intalled MS Excel 2007 on my Dev Server. Here is the error that I am receiving....
Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidCastException:
Unable to cast COM object of type 'Microsoft.Office.Interop.Excel.ApplicationClass' to interface type 'Microsoft.Office.Interop.Excel._Application
'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{000208D5-0000-0000-C000-000000000046}'
failed due to the following error: Library not registered.
Please help me, this is very urgent.
Thank You.No I didn't upgrade my SQL Server. OMG this error making me ehhhhhh.
Here I solve my problem.
RUN>REGEDIT> and look for "Office.Interop.Excel" and delete the old version. I am using Excel 2007, 14.0.
It solve my Problem.
Thanks All. -
Error in script task "The name 'file' does not exist in the current context"
I am new to the c# scripting and SSIS come from PHP and Foxpro.
I am using SSIS with a script task and I am getting am errror "The name 'file' does not exist in the current context" in the following code in the picture below: (See
Why does the object named "file" go away after the first refrence to it?? How do I make it avaliable for the whole script??
public void Main()
String cFileInfo = null;
DateTime dFTPFileDateTime;
bool fireAgain = true;
List<IRemoteFileInfo> fileList = (List<IRemoteFileInfo>)Dts.Variables["SFTPResult"].Value;
foreach (IRemoteFileInfo file in fileList)
cFileInfo = file.Name + "|" +file.ModifiedTime +"|"+ file.Size;
Dts.Events.FireInformation(1, "Name ", cFileInfo, "", 0, ref fireAgain);
dFTPFileDateTime =
file.ModifiedTime;
<< This is where the error is occuring.
Dts.TaskResult = (int)ScriptResults.Success;I think you forgot { and } after the loop... Or is that deliberately?
Please mark the post as answered if it answers your question | My SSIS Blog:
http://microsoft-ssis.blogspot.com |
Twitter -
Hi Experts,
I am trying to open .xlsx file in script task of SSIS 2005. I am using the 32-bit AccessDatabaseEngine driver with the Connection string as "Provider= Microsoft.ACE.OLEDB.12.0; Data Source=xlsx file path; Extended Properties="Excel 12.0 Xml;
HDR=YES"" in script task.
When we debug the VB script in Visual Studio 2005 and encounters the statement app.open() it throws the error "Couldn't find installable ISAM".
My SQL server version is 2005 SP2 DE
OS is Windows server 2003 EE SP2
Could anyone please let me know what is the resolution for this error?
Thanks and Regards,
AdeshHi Adesh,
First, make sure the package runs in 32-bit runtime mode (set Run64BitRuntime property to False) because you are using the 32-bit ACE OLE DB Provider. If it is not the case, the issue may occur due to the corrupted drivers or registry keys. You can try to
reinstall the 2007 Office System Driver: Data Connectivity Components as Arthur suggested.
Regards,
Mike Yin
TechNet Community Support
Maybe you are looking for
-
I am having a great deal of trouble with the upgrade to ios 7 on my 4S. The syncing and the software updates always leave generic icon apps that I have downloaded in the past but have deleted from my phone. But they keep reappearing. A restart of the
-
Hi, I would like to know if an item can be searched by Manufacturer Part Number or Supplier Item Number from the Purchase Requisition and Purchase Order Forms. Currently we are able to search only by Item Code, Item Description & UOM. Thanks!
-
How to see what are the tablespaces in a database
Hi..All.. I want to see what are the tablespaces present in my database. What is the query for it..? Thanks in advance, Pal
-
Integration with contact database
Hi, We have built a custom contact database. Contacts (including email addresses etc) are stored in an Oracle 8 database. We are looking for a product integrating email/documents and our contact database. Now I have read about Collaboration Suite. Is
-
LV2011, cant check other versions right now. The Connector pane pattern window doesn't mark/show your currently selected pattern. Not a big bug, but i still classify it as such. /Y LabVIEW 8.2 - 2014 "Only dead fish swim downstream" - "My life for Ku