what determines the order in which things in foreach loop are processed
C# Script Task Error: NullReferenceException when run on Server
I have a package with a C# Script Task. When I run the package on my PC it runs fine. When I run it from a job on the 2008 R2 SQL Server, I get an error:
System.NullReferenceException: Object reference not set to an instance of an object.
Here is the code from the 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 Microsoft.Office.Interop.Word; using System.IO; namespace ST_81404bfc4f6042a690e05f2203277b8c.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() { object objNull = System.Reflection.Missing.Value; object objTrue = true; object objFalse = false; object objOpenFormat = Microsoft.Office.Interop.Word.WdOpenFormat.wdOpenFormatAuto; object wdFormat = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatPDF; object doNotSaveChanges = Microsoft.Office.Interop.Word.WdSaveOptions.wdDoNotSaveChanges; string strDocFolder = "\\\\server01\\shared$\\Docs\\"; string strFileName = "Document_4"; object strTemplatePath = strDocFolder + strFileName + ".TEMPLATE.docx"; string strCreatedDate = (string)Dts.Variables["User::decCreatedDate"].Value; string strPdfFolder = "\\\\server01\\shared$\\Docs\\Storage\\" + strCreatedDate + "\\"; object strPdfFile = strPdfFolder + strFileName + ".pdf"; Microsoft.Office.Interop.Word._Application wrdApp = new Microsoft.Office.Interop.Word.Application(); Microsoft.Office.Interop.Word._Document wrdDoc; Microsoft.Office.Interop.Word.MailMerge wrdMailMerge; if (!Directory.Exists(strPdfFolder)) { Directory.CreateDirectory(strPdfFolder); } wrdDoc = wrdApp.Documents.Open(ref strTemplatePath, ref objFalse, ref objTrue, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objFalse, ref objNull, ref objNull, ref objNull, ref objNull); wrdApp.Visible = false; wrdDoc.Activate(); wrdMailMerge = wrdDoc.MailMerge; wrdMailMerge.Destination = Microsoft.Office.Interop.Word.WdMailMergeDestination.wdSendToNewDocument; wrdMailMerge.Execute(ref objFalse); //wrdDoc.Close(ref objTrue, ref objNull, ref objNull); wrdApp.ActiveDocument.SaveAs(ref strPdfFile, ref wdFormat, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull); wrdApp.Documents.Close(ref doNotSaveChanges, ref objNull, ref objNull); wrdApp.Quit(ref objFalse,ref objNull,ref objNull); if (wrdDoc != null) System.Runtime.InteropServices.Marshal.ReleaseComObject(wrdDoc); if (wrdApp != null) System.Runtime.InteropServices.Marshal.ReleaseComObject(wrdApp); wrdMailMerge = null; wrdDoc = null; wrdApp = null; Dts.TaskResult = (int)ScriptResults.Success; } } }
According to the DBA, Word is installed on the server.
The Microsoft.Office.Interop.Word version is 12.
When I changed it to 14, it through an error that it could not be loaded.
SSIS and report cache
I have several reports loaded on the report server with caching options set. I have this list of reports loaded in a database table where an SSIS package iterates through that table rendering each report and sending a link to the report in an email. I was hoping just rendering report in the SSIS package would cache it and then the user clicking on the email link would be pulling it from cache. This doesn't seem to be the case.
Script Component:
rs.LoadReport(Row.reportPath, null);
ParameterValue[] paramval = new ParameterValue[2];
paramval[0] = new ParameterValue();
paramval[0].Name = "mth";
paramval[0].Value = mth.ToString();
paramval[1] = new ParameterValue();
paramval[1].Name = "yr";
paramval[1].Value = yr.ToString();
rs.SetExecutionParameters(paramval, "en-us");
format = Row.reportFormat.ToString(); //excel
results = rs.Render(format, deviceInfo, out extension, out encoding, out mimeType, out warnings, out streamIDs);
Link in email looks like: http://myreportserver/ReportServer/Pages/ReportViewer.aspx?%2fSAREQS%2frdschlrpt1&mth=7&yr=2012&rs:Command=Render&rs:Format=Excel
Error deploying SSIS 2012 to Catalog DB
Hi,
Am having an intermittent issue that happens when deploying to an SSIS Catalog (in the "Deploying project" step). basically sometimes when deploying an SSIS project to a Catalog that I administer, I receive an error telling me to lookup a particular operation
error message in the [catalog].[operation_messages] VIEW in the SSIS Catalog DB (and gives me an operation ID), the error in the view above is:
The project or operation records do not exist or you have not been granted the appropriate permissions to view them.
Now I am sure there is no rights or permission issues, and if I try deploying the project again (without changing any deployment parameters) there is no issue (albiet it might take a couple of tries). There is no SSIS packages running during the time I am deploying and all server resources seems to be fine.
Am not entirely sure what's going on here.
For loop executing SQL task every 15 minutes until flag changes
Hello,
I have a working SSIS package. I need to add functionality that checks a column in a database every 15 minutes. I have a SQL task that populates a variable with the value from the database table, but I am not sure how to have it execute every 15 minutes until the value changes. I know how to set up the precedence constraints once I have the value, so that is not an issue. I am just having trouble setting up this functionality.
Any help would be appreciated
Dave
Dave SQL Developer
SSIS is not using the provided custom Sharepoint credentials
Hello,
I have multiple packages that need to access a Sharepoint server. So I am using the popular package from here:
http://sqlsrvintegrationsrv.codeplex.com/releases
The way I have it set up, is that there is a job in SQL Server that runs multiple packages every day, however when it tries to run them, it does not work. I am getting authentication and validation errors.
When I run the packages locally, it works fine.
After investigating, I found out that the credentials I provide to connect to Sharepoint are not used. The package uses my windows account even if I specifically set it to use custom credentials. To test this, I simply created a new account on my computer and ran the package with correct custom credentials and found that it didn't work. If I do the same on the account that has access to Sharepoint, it works.
I would like to know if there is a fix or a workaround for this ?
Thank you,
Yan
SSIS Package variable changes type at run time
I have a package that I have just added a new variable to. The new variable's scope is package-level, the type is string, and the initial value is empty.
Then I set the value of that variable at run-time with a script task.
When I executed the package, it gave me an error that I was trying to change the data type of a variable which is not allowed.
I ran the package in the debugger, and when I put a watch on the new variable, it reported the datatype as Int32. I look up and to the left, and in the Variables window, the type of that same variable is clearly "String".
Anybody ever had this happen? I googled, and apparently I'm the first ever as far as I can tell. I've tried giving the variable a default string value at design time, and still it changes the datatype of the variable to Int32 with a value of 0 when it runs.
Anybody else got any ideas for me?
-Tab Alleman
updating large table
Hi,
I have two tables tb1(KEY,IDS,col2,col3,col4) and tb2(key,col) each table has 90 milion records and i am updating tab2 data to tb1 using KEy coulmn
UPdate tb1
set IDS=col from tb2
where tb1.KEy=tb2.key
But it is taking to long to load the data in to main table can any one suggest me how to update quickly
ssis object reference not set to an instance of an object
I am using a script component with the script given below:
' Microsoft SQL Server Integration Services user script component ' This is your new script component in Microsoft Visual Basic .NET ' ScriptMain is the entrypoint class for script components Imports System Imports System.Data Imports System.Math Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper Imports Microsoft.SqlServer.Dts.Runtime.Wrapper Public Class ScriptMain Inherits UserComponent Dim mx As String Dim mn As String Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer) ' ' Add your code here ' mx = Row.MAXVPD.ToString() mn = Row.MINVPD.ToString() End Sub Public Overrides Sub PostExecute() mx = mx.ToString() mn = mn.ToString() ReadWriteVariables("Max_VPD").Value = mx ReadWriteVariables("Min_VPD").Value = mn MyBase.PostExecute() End Sub End Class
But when I run my package, I am getting an error 'object reference not set to an instance of an object'
Can someone tell me whats the problem here..thanks in advance
how to add 2 variables using expressions in filesystem task ?
Can we add 2 locations using expressions in file system task ?
Usually there would be a property called conenction string which can used to add 2 variables .Do we have any such thing in file system task ?
best practice for aborting a pkg
Hi. We have a master pkg that calls a very large number of sub packages.
We run std 2008. Is there a best practice for aborting everything? Perhaps throwing an exception in a script or dividing by 0 or using some off the shelf ssis feature for stopping any further execution?
I saw one post where a stop execution method was called but it wasnt clear how and where to use it and if it could be executed from wuthin the process itself.
multiply with the qty value.
Hi Gurus,
I have a requirement to calculate "Result" column as below: Here, we are multiplying by taking the Item# by an integer. lets take ex: for (1,1.1,1.2) the qty is 5 for Item# 1. So, for each qty in like 1.1,1.2 we multiply by 5 so we get 10,5 resp. in the result column. How can I do this in SSIS . Please help me with this.
Item# qty Result
1 5 5
1.1 2 10
1.2 1 5
2 3 3
2.1 1 3
2.2 2 6
2.3 2 6
File is locked by SSIS script task that copies the file to a new location
Execute Package Task
Hi,
I have developed 10 SSIS packages and would like to execute them using the Mater -Child Package set-up. I would like to know how can we run multiple packages using the execute package tasks in a certain defined order.
Can we have a file which stores package name , execution order and loop through using the For Each Loop container.
Please advice the various steps I would need to follow inorder to execute multiple child packages in a defined order using one execute package tasks .
Thanks,
eva
EVA05
Perform database actions using command line output
Hi,
I have hit a deadend on this one.
Could someone please tell me how can i use the execute process task to run a command which is the statement that i would run using the command prompt but allows me to save the output of the statement that i have run.
For example: we retrieve our passwords from a secure database using something like as follows:
pwecho <servername> <user_id>
this statement when run from the command prompt returns the password for the user_id on that server.
I would like to use the SSIS execute process task and save the returned password string into a variable and then save it into a row in a database table.
If this works. It woudl replace a very cumbersome process that we have right now for retrieving the secure passwords.
please help.
could not find getReportParameters or getItemParameters from ReportService2010
Hi All,
I am writing script to get total number of parameters for the report, but could not find getReportParameters or getItemParameters from ReportService2010, could anybody help?
Thanks a lot!
Ling
SP executed around 6 mins in Execute SQL Task but still executing from past 30 mins in SSMS.
Two questions about SSIS on SBS 2011?
Hi guys,
We have a server running a standard SBS 2011 install (I don't know which edition), so I imagine it also has SharePoint and SQL Express. I'd like to create an SSIS package for ETL purposes, using both x64 and x86 providers. For political reasons, I don't want to ask the admins for any specific information at the moment. I know that's a PITA, but I beg your understanding. My questions are as follows:
First: If I assume a standard SBS install, does the above server already have the SSIS runtime installed? If not, am I able to download it for free? I don't have an MSDN subscription any more.
Second: The source files will be a mix of Excel x64 & x86, and Access x64. Do I need to download and install the x86 Jet provider for Excel and the x64 provider for ACE?
Many thanks in advance,
Graham
Regards, Graham R Seach Sydney, Australia
ssis change datatype from one table to another
Hello guys,
I need some help. I have to tables(table1, table2) in my database.(SQL Server 2005)
Initially i created an ssis Package to import data from excel files to table1. The datatype for each columns are "nVarchar(255)". It works very well.
The table2 has columns with different datatype. such as varchar, decimal(10,2), datetime.
What i want to do?
I want to create a new ssis package to import data from table1 to table2 converting the datatype of "nvarchar" from table 1 to their respective datatype in table2. can you give some steps of how to do this.
please help. i am new to ssis since 3 weeks only.
thanks vayl1.
ForLoop Eval Expression
Hi Team,
We have a scenario where we have to check two tables(say table1 primary and table2 back up) continuously and the data should be pulled as soon as one of the table is loaded. To do this we have used a ForLoop which is checking for two variable values(this value is Rowcount of the tables) continuously and whenever the value of any one variable is greater than 0, ForLoop should be success and it should proceed to pull the data.
Inside the ForLoop we have two ExecuteSQL task which is counting(Select Count(*) from table1) the number of rows in table1 and table2 and assigning it to the variables (@LoopRecordCountPrimary and @LoopRecordCountSecondary).
The EvalExpression for ForLoop is (@LoopRecordCountPrimary==0) || (@LoopRecordCountSecondary==0)
Now the issue is, ForLoop is becoming success only when both the variables are having values greater than 0, but we want it to become success when one of the variable is greater than 0.
I request you to please suggest or guide us. Thanks much for your time.
Regards
Jim