C# SSIS Script component - Save List String to Object package-scope variable and read it in Script Task
before posting this i was searching this on internet but was not able to find info regarding my specific case:
i have a DataFlow Task with "Error output" pointing from FlatFile to
Script Component that does below (variable "ErrorMessageList" is listed under ReadWriteVariables property):
List<string> lsErrors = new List<string>();
public override void Input0_ProcessInputRow(Input0Buffer Row)
lsErrors.Add("test1");
lsErrors.Add("test2");
void PostExecute()
base.PostExecute();
Variables.ErrorMessageList = lsErrors;
Then the DataFlow points to a ScriptComponent where this object variable is listed under ReadOnlyVariables property and does the below:
public void Main()
List<string> lsErrors = (List<string>)Dts.Variables["ErrorMessageList"].Value;
and that is where i get exception-has-been-thrown-by-the-target-of-an-invocation
What is wrong here?
(i have mistakenly edited this first post before, so i tried to manually put it back to original version)
i have missed the "override" keyword...
public class ScriptMain : UserComponent
public class UserComponent: ScriptComponent
namespace Microsoft.SqlServer.Dts.Pipeline
public class ScriptComponent
// i should have seen this before
public virtual void PostExecute();
i believe i must have deleted the PostExecute method definition right after the ScriptComponent generated the script for me... and then when i've realized that i can't change ReadWriteVariables as a part of:
public override void Input0_ProcessInputRow(Input0Buffer Row)
// --- can't change ReadWriteVariables here
then i had to add the method back but forgot that the base method is virtual
thanks for this hint, Russ!
Similar Messages
-
Running a Select query against multiple sql servers using SSIS script task.
Hi Guys,
I need to fetch data from multiple sql servers using SSIS scirpt task inside a foreach container.
is there anyway i can build dynamic sql connections using ssis variables inside SSIS script task in each loop
Please guide me or refer any blogs so that i will try..
Thanks in advance.Your only options is using .net code, then it will be no different than using a console app in a loop.
using (SqlConnection connection = new SqlConnection(connectionString))
connection.Open();
Console.WriteLine("ServerVersion: {0}", connection.ServerVersion);
Console.WriteLine("State: {0}", connection.State);
and so forth for each connection string
the connection string would come from the ForEach loop
Arthur My Blog -
Convert ActiveX DTS script task to SSIS Script task - Please help
Hello,
I Have a ActiveX script that was used in a DTS package but I'm currently trying to convert all my DTS packages to SSIS.The script is tasked to run the package on a daily basis. Everything works fine except the ActiveX script. It gives an error on my DTSGlobalVariables.parent,
I looked up this error and changed it to "DTS.Variables("User::VariableName").Value", in
the SSIS script task (in VB) but now I'm getting error:
Microsoft.SqlServer.Dts.Runtime.DtsRuntimeException: The element cannot be found in a collection.
---> System.Runtime.InteropServices.COMException (0xC0010009): The element cannot be found in a collection.
bij Microsoft.SqlServer.Dts.Runtime.Wrapper.IDTSVariables100.get_Item(Object Index)
bij Microsoft.SqlServer.Dts.Runtime.Variables.get_Item(Object index)
--- Einde van intern uitzonderingsstackpad ---
bij Microsoft.SqlServer.Dts.Runtime.Variables.get_Item(Object index)
bij ST_f32fc12b60f34bebbbdfc0c5e5b40a96.vbproj.ScriptMain.Main()
--- Einde van intern uitzonderingsstackpad ---
bij System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
bij System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
bij System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
bij System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
bij System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
bij System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, CultureInfo culture)
I have tried to convert this ActiveX script into a SSIS script task in VB but I know hardly any VB... So I'm wondering what the best course of action for me is, should I try to convert it into the script task like I am trying now, if so, how do I make it
work?
Any help would be really really welcome.
This is the original ActiveX script that needs to be converted:
' Visual Basic ActiveX Script
Function Main()
Dim sEnvironm
Dim sServer
Dim sSourceFile
Dim sSourcePath
Dim sBackupPath
Dim sErrorPath
Dim sFileName
Dim sUDLPath
' Set vars
' First 2 are depending on the server and db
' FILL IN THE RIGHT VALUES
sEnvironm = "MON_Datamart"
sServer = "BrechtProesmans"
' --- DO NOT CHANGE ANYTHING BELOW THIS LINE ---
sSourceFile = "C:\Program Files\Microsoft SQL Server\MON_Datamart\SourceFiles\tbl_L00T1.txt"
sSourcePath = "C:\Program Files\Microsoft SQL Server\MON_Datamart\SourceFiles\"
sBackupPath = "C:\Program Files\Microsoft SQL Server\MON_Datamart\BackupFiles\"
sErrorPath = "C:\Program Files\Microsoft SQL Server\MON_Datamart\ErrorFiles\"
sFileName = "tbl_L00T1.txt"
sUDLPath = "C:\Program Files\Microsoft SQL Server\MON_Datamart\MON_Datamart.udl"
' Initial
FoundError = False
' Get a handle to the Package object.
Set oPackage = DTSGlobalVariables.Parent
' Update DTSConnections
Set oConnection = oPackage.Connections("tbl_L00T1.txt")
oConnection.DataSource = sSourceFile
Set oConnection = oPackage.Connections("Datamart")
oConnection.UDLPath = sUDLPath
Set oConnection = oPackage.Connections("Truncate")
oConnection.UDLPath = sUDLPath
' Update DTSTasks
Set oTask = oPackage.Tasks("DTSTask_DTSDataPumpTask_1").CustomTask
oTask.SourceObjectName = sSourceFile
oTask.DestinationObjectName = sEnvironm & ".dbo.stg_tbl_L00T1"
' Set Global vars
DTSGlobalVariables("SourcePath").Value = sSourceFile
DTSGlobalVariables("BackupPath").Value = sBackupPath
DTSGlobalVariables("ErrorPath").Value = sErrorPath
DTSGlobalVariables("FileName").Value = sFileName
' Clean up.
Set oTask = Nothing
Set oConnection = Nothing
Set oPackage = Nothing
Main = DTSTaskExecResult_Success
End FunctionSet a breakpoint and tell us on what line it dies, at the same time, you can inspect the variable values in the Auto window (if there are) as it merely perhaps is an issue with values not being passed in.
Arthur
MyBlog
Twitter -
NameSpace for XML But in SSIS Script Task
Hello,
I am creating an xml Document that pulls information from a staging table in sql. However the issue I am having is that i need a namespace or a start element to handle a ':' but i keep getting its not a hexadecimal blah blah.
I feel like I have tried everything for this.
So maybe someone can help me
writer.WriteStartDocument()
writer.WriteComment("edited with XMLSpy v2010 rel. 3 (http://www.altova.com) by MESMERiZE (MSM)")
writer.WriteComment("Samply XML file generated by XMLSpy v2010 rel. 3 (http://www.altova.com)")
So i have the comments show up fine but then i need it to show
<mssext:sendWarrantyContractBatch xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mssext="http://jlrint.com/mss/message/sendwarrantycontract/1" xsi:schemaLocation="http://jlrint.com/mss/message/sendwarrantycontract/1
FRS_000143-SendWarrantyContractMessages.xsd">
I can get the websites and all the xmlns to show up fine that is not the issue the issue is the mssext:sendWarrantyContractBatch
IS there any way to get the Colon to show up ??
Remember this is in a ssis script task with visual basic 2008 codecheck this link. it has a method specified in the comments section
http://blogs.lessthandot.com/index.php/datamgmt/dbprogramming/create-xml-files-out-of-sql-server-with/
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
Consuming Web Services in SSIS Script Task
Hello
Sorry for my English, I' ll try to explain my problem.
I am new to SSIS. Using this article http://blogs.msdn.com/b/dataaccesstechnologies/archive/2010/01/28/consuming-web-services-in-ssis-script-task.aspx I have tried to consume web service.
1. I have created proxy class using VS Command Prompt
2. A have added proxy class to Script Task
3. But when I want to create the instance of the proxy class, it can be accessed from the ScriptMain.cs.
I will be very pleased for the help!perhaps you missed this step:
--> Modify the code and add Credentials before calling the web method:
Public
SubMain()
Dim
ws As NewService1
ws.Credentials =
New System.Net.NetworkCredential("user name",
"password",
"domain name")
MsgBox("Square
of 2 = "& ws.Square(2))
Dts.TaskResult = Dts.Results.Success
End
Sub
Arthur
MyBlog
Twitter -
Getting COM Component error while opening SSIS Script task.
Hi All,
While click on EDIT SCRIPT Button in script task it's not opening the script editing window.
Getting below error message:
"Error HRESULT E_FAIL has been returned from a call to a COM component. (EnvDTE)"
We have added ADODB reference in script task.
Thanks in advance, please give some suggestion.I am using SSIS 2008 R2.
When I reload the package, script task visual studio opens first time, next time when I try to open script task visual studio from EDIT SCRIPT Button it gives below error:
"Error HRESULT E_FAIL has been returned from a call to a COM component. (EnvDTE)" -
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. -
SSIS Script task not executing macro through SQL Agent (but it does through bids)
<p>Hello everyone,</p><p>I am having an issue with SQL Agent when executing a macro contained in a script task component. The script task actually opens an excel file, runs the macro, save and closes the file. </p><p>When
I execute the package via BIDS/Visual studio, it works like a charm. However, when i execute the package with SQL agent, the package runs successfully but it seems that the macro is not executed as the excel file has not been modified as it should have. Also,
the history log does not show any error messages. </p><p>Could </p>Thanks!I did create a credential and a proxy too but still the macro is not executed.I have searched online for solutions but no one has experimented this kind of issue before it seems. Please have a look at the script task code:
Imports
Excel = Microsoft.Office.Interop.Excel
Imports
System
Imports
System.Data
Imports
System.Math
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 Macro_name
As
String
Dim ExcelObject
As
New Microsoft.Office.Interop.Excel.Application
Dim oBook
As Microsoft.Office.Interop.Excel.Workbook
Dim oBooks
As Microsoft.Office.Interop.Excel.Workbooks
Try
Macro_name =
"Macro001"
ExcelObject =
CType(CreateObject("Excel.Application"),
Excel.Application)
ExcelObject.Visible =
True
ExcelObject.UserControl =
False
ExcelObject.DisplayAlerts =
False
oBooks = ExcelObject.Workbooks
oBook =
CType(oBooks.Open("C\Book1.xls"),
Excel.WorkbookClass)
ExcelObject.Run(Macro_name)
Catch ex
As Exception
ExcelObject.Application.Quit()
ExcelObject.DisplayAlerts =
True
ExcelObject =
Nothing
End
Try
Dts.TaskResult = ScriptResults.Success
End
Sub
End
Class -
Hello All,
Here is what I am trying to do...
1. I am having two rows, one column in an Object Variable. (vLoopCountObj).
2. I am having 30 Rows, 2 Columns in my second Object Variable (vTableRowsObj)
3. I have a FOR EACH LOOP which will run for number of rows in vLoopCountObj i.e 2 times here.
4. I have a Script Task inside the FOR EACH LOOP to display all the rows of vTableRowsObj.
5. When I execute, 30 Rows gets displayed only once. It will not display when the loop goes for second iteration. Please help me to display for second time.
6. I have used below code to display the rows whithin the script task which is in SSIS dataflow task.
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Imports System.Xml
Imports System.Collections
Imports System.Data.OleDb
Public Class ScriptMain
Public Sub Main()
Dim oleDA As New OleDbDataAdapter
Dim dt As New DataTable
Dim col As DataColumn
Dim row As DataRow
Dim sMsg As String
oleDA.Fill(dt, Dts.Variables("vTableRowsObj").Value)
MsgBox("Number of Rows " + dt.Rows.Count.ToString())
For Each row In dt.Rows
For Each col In dt.Columns
sMsg = sMsg & col.ColumnName & ": " & row(col.Ordinal).ToString & vbCrLf
Next
MsgBox(sMsg)
sMsg = ""
Next
Dts.TaskResult = Dts.Results.Success
End Sub
End ClassHi Raj,
It is verrrry interesting issue. I can also confirm that it doesnt loop again. I've made a simple test and figured that in the second loop even you fill the Dataadapter, record count is zero. Which brings me up to the idea: Somehow, after you read the object
variable resultset, you can not read it again in the for each loop.
Strange, probably a bug or a technical issue that is beyond my existing knowledge.
I can provide a workaround. You can also loop in script task for first variable. (Nested loops)
Let other members to examine and comment on this.
Regards
Onur
(For others who also wants to test, here is my scenario
Execute SQL Task 1:
Query: SELECT 1 as Cnt UNION ALL SELECT 2 as Cnt
Resultset: Full Resultset
ResultSet Tab: Name: 0, Variable Name: User::vLoopCountObj;
Execute SQL Task 2:
Query: SELECT 1 as ColA, 2 as ColB UNION ALL SELECT 3 as ColA, 4 as ColB UNION ALL SELECT 5 as ColA, 6 as ColB
Resultset: Full Resultset
ResultSet Tab: Name: 0, Variable Name: User::vTableRowsObj;
For Each Loop Container:
Collection: Enum: ForEach ADO Enum
Source Object: User::vLoopCountObj
Enum Mode: Rows n the first Table
Script Task:
ReadOnlyVariables: User::vTableRowsObj
Script Source:
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Imports System.Xml
Imports System.Collections
Imports System.Data.OleDb
Public Class ScriptMain
Public Sub Main()
Dim oleDA As New OleDbDataAdapter
Dim dt As New DataTable
Dim col As DataColumn
Dim row As DataRow
Dim sMsg As String
oleDA.Fill(dt, Dts.Variables("vTableRowsObj").Value)
Dts.Events.FireInformation(-1, "START!!!!!!!!!!!!!!", "START LOOP", "", 0, True)
Dts.Events.FireInformation(1, "RowCount: ", dt.Rows.Count.ToString(), "", 0, True)
For Each row In dt.Rows
For Each col In dt.Columns
sMsg = sMsg & col.ColumnName & ": " & row(col.Ordinal).ToString & vbCrLf
Next
Dts.Events.FireInformation(1, "Msg: ", sMsg, "", 0, True)
sMsg = ""
Next
Dts.TaskResult = ScriptResults.Success
End Sub
End Class
BI and ERP Senior Consultant @ Nexum Bogazici
If it is, Please dont forget to mark as answered or at least vote as helpful if the post helps you in any ways. -
I have a script task written in C# that creates an array of strings "arrayFields" after parsing a text file. It saves the array of strings in a DTS variable.
Each row in array represents a row is comma separated and is a row that must be inserted into a table. For example,
X and Z are fields in the table
X1, X2,....Xn
Z1,Z2,...Zn
I am using a Foreach Loop to grab each row and then Execute SQL Task to take each row from the array and insert each field per row in a table,
The SQL is something like,
INSERT dbo.table values(field1, field2,...fieldn) arrayFields?
What should this this INSERT look like?I guess you implemented
Shredding a Recordset
Based on what I understood (correct me if I am wrong) you have difficulties mapping the input parameters, if so here is the guide
http://www.sqlis.com/sqlis/post/The-Execute-SQL-Task.aspx
In short it might look like
INSERT dbo.table (ColumnA, ColumnB,...) VALUES (?,?...)
The syntax for the T-SQL INSERT is http://technet.microsoft.com/en-us/library/dd776381%28v=sql.105%29.aspx
Arthur
MyBlog
Twitter -
Creating Excel using C# in SSIS Script task.
Hi Guys,
I need to dynamically create an excel (with rows and columns) from a script task in a foreach container and just send an email to a group..
Can anyone guide me on this..
Thanks in advance...Hi,
There are a number of things wrong with this request.
1. This is a scripting forum, not a C# development forum.
2. This is not an SSIS forum.
3. You show nothing about what you have already tried, what has worked, and what hasn't worked.
Your question is far too broad and vague, and you're not even asking in the right place.
You need to break down your requirements into small pieces and ask very specific questions in the correct forums. If you need for someone to design a solution for you, it's better to hire a paid consultant.
Bill -
SSIS script task using visual c# 2012 language when creating package in Visual Studio 2013
Is it right or my installation was all wrong.
When I am trying to use a script task in an SSIS package using Visual Studio 2013, the available languages are visual c# and VB 2012.
I was expecting to find visual c# and VB 2013 since I was using Visual Studio 2013.
I already installed the "Microsoft SQL Server Data Tools - Business Intelligence for Visual Studio 2013" available for sql 2014
Please help clarify this. Thanks beforehand.
PaulinoHi Paulino,
According to your description, the ScriptLanguage property of C# script tasks show "Microsoft Visual C# 2012” in SSDT-BI for VS 2013.
After testing the issue in my environment, I can reproduce it in SSDT-BI for VS 2013. And I find that the ScriptLanguage property of C# script tasks show "Microsoft Visual C# 2010” in SSDT, and show "Microsoft Visual C# 2012” in SSDT for SSDT –
BI for VS2012. It only appear in SSDT-BI for VS 2013.
The issue is by design. But we can check "Do not show this again." to ignore the dialog and the task can be executed without any problem.
The following feedback is for your reference:
https://connect.microsoft.com/SQLServer/feedback/details/1027035/ssdt-bi-for-vs-2013-compatibility-issue
Regards,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
Using Mac 10.9.2 and Reader 11.0.6 and Safari 7.0.2, problem seems to be linked to Safari
Files - using "save as" (.pdf) or "print as" (.pdf) appear as adobe single-page blank documents. When attempting to open them the following error message appears: "Adobe Reader could not open "filename.pdf" because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded).
Files created under previous versions of Reader are fine. No problem converting an existing .doc to .pdf using Reader 11.0.6
Any suggestions?Hi ramsey32 ,
Thank You for posting in the forums. Kindly help with the information listed below for further assistance.
1) Does the PDF open fine in safari
2) Do you get a floating toolbar at the bottom, if yes, choose the save icon from there to save the PDF
3) Do the files open fine with Preview?
Thanks,
Vikrantt Singh -
SSIS script task failing when deployed as project in SSIS 2012
Yes , it's the classic "my package works inside SSDT but dies when I deploy it". I have a fairly good idea what the problem is. I have a line of code that looks in a directory. My guess is that the account that is used to run packages out
of SSISDB doesn't have access to the directory in question. My question is, what exactly needs to be set properly in order for packages to run properly in the package deployment model.
Error message: Exception has been thrown by the target of an invocation.
Code:
using System;
using System.Data;
using System.IO;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
public void Main()
String FilePath;
FilePath = Dts.Variables["InitialDirectoryFullPath"].Value.ToString();
if (Directory.GetFiles(FilePath).Length == 0)
Dts.Variables["FilesExist"].Value = false;
else
Dts.Variables["FilesExist"].Value = true;
Dts.TaskResult = (int)ScriptResults.Success;
enum ScriptResults
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.FailureYou need to give the account which is executing package the access to the directory. If its from SQL Agent job, it might be using SQL Agent service account by default. Then you've to give it required permissions
Alternatively you can create a proxy account with required permissions and configure the job to use it
http://www.mssqltips.com/sqlservertip/2163/running-a-ssis-package-from-sql-server-agent-using-a-proxy-account/
Also you've not posted error message. Whatever I've suggested is by assuming that its a permission issue. If you can post error message we might be able to confirm on the actual cause of error.
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
Using SSIS Script task to populate data from one table to another
I have two tables Table A and Table B. Need to insert data into Table B from Table A. First, I truncate Table B and then insert. Few columns in Table A and Table are similar. However, I need to join with
other tables Table C, Table D etc with Table B in order to populate the columns in Table B. Could someone please provide the code snippet to achieve this.Appreciate your quick response Prasad. Below is the code I'm using to achieve.
Public Sub Main()
Dim connEOCDB As SqlClient.SqlConnection = GetDBProdConnection(Me)
Dim trans As SqlClient.SqlTransaction = connEOCDB.BeginTransaction()
Try
Dim TableA As New DataTable
Dim TableB As New DataTable
Dim DataadapterTableA As New SqlClient.SqlDataAdapter()
DataadapterTableA.SelectCommand = New SqlClient.SqlCommand("select * from TableA", connEOCDB, trans)
DataadapterTableA.Fill(TableA)
Dim DataAdapterTableB As New SqlClient.SqlDataAdapter()
DataAdapterTableB.DeleteCommand = New SqlClient.SqlCommand("Truncate table dbo.TableB", connEOCDB, trans)
DataAdapterEmpExtdT.InsertCommand = New SqlClient.SqlCommand("insert into dbo.TableB (Col1,Col2,Col3,.....) values (@Col1,@Col2,@Col3...)", connEOCDB, trans)
Could you please let me know how I can assign values to @Col1, @Col2 etc from
DataadapterTableA.Fill(TableA). Also, as mentioned earlier, I need to use joins to populate @Col3 etc as well.
Please advise.
Maybe you are looking for
-
I have GarageBand for iPad 2 and noticed that there are far fewer loops for iPad than for apple laptops. Is there a library available of apple loops? I haven't been able to find any if there are. Any help would be greatly appreciated.
-
Deserialization permissions error in CLR stored procedure
Environment: SQL Server 2008 R2 standard edition and VS2010, .Net Framework 3.5 I've got a table with a varbinary column that contains a serialized Hashtable. I'm writing a CLR stored procedure that, given the contents of such a field from a row in t
-
Sorry Demo but your reply did not work, I tried to download some music but all it did was revert back to re-send the agreement to me, the AGREE button to click did not appear, why cant you put the "AGREE" button on the bottom of the agreement page, i
-
I have successfully created a flash jukebox in an iWeb web site!!!
Here it is. http://www.holyredeemernorthbend.org/HRWeb/Welcome.html Thanks to Mr Toad and everyone else who helped. If you want to know how I did it, I will post it to the above link this weekend. Thanks again!
-
Hi, all please let me know it is possible we use one developer key two system.we have same sid and same host name and it is install same solman key.and same user name. Thanks kumar