How Doo I Get Database Connection From SSIS Script Task?
Dec 18, 2007
When I try this code in an SSIS "Script Task":
Dim dbConnectionManager As ConnectionManager = Dts.Connections(0)
Dim dbConnectionRaw As Object = dbConnectionManager.AcquireConnection(Nothing)
Dim dbConnection As OdbcConnection = CType(dbConnectionRaw, OdbcConnection)
I get this error:
Unable to cast COM object of type 'System.__ComObject' to class type 'System.Data.Odbc.OdbcConnection'. Instances of types that represent COM components cannot be cast to types that do not represent COM components; however they can be cast to interfaces as long as the underlying COM component supports QueryInterface calls for the IID of the interface.
I'm just trying to get a basic database connection from the DTS package in my
script task. Is there a better way to do this? Preferably, I would use ADO.NET
rather than the old COM stuff. However, if SSIS still requires the use of COM,
that's fine as well, as long as I can fix the above code.
I added a connection (ADO.NET) object by name testCon in the connection manager - I wanted to programmatically supply the connection string. So I used the "Expressions" property of the connection object and set the connectionstring to one DTS variable. The idea is to supply the connection string value to the variable - so that the connection object uses my connection string.
Then I added a "Backup Database Task" to my package with the name BkpTask. Now whenever I try to set the connection property of BkpTask to the testCon connection object, by typing testCon, it automatically gets cleared. I am not able to set the connection value.
Then after spending several hours I found that this is because I have customized the connection string in testCon. If I don't customize the connection string, I am able to enter the "testCon" value in the connection property of the BkpTask.
Hi, under the script that I use for upload file using SSIS asp.net task.
My problem.... If I comment this line 'ftp.SendFiles(files, "", True, False) ' the True makes it overwrite existing
upload made successfull without failure instead If I leave uncomment I got an error but files upload anyway correct.
Someone can give me some explains about this behavior? TNKS Alen, Italy
------------------ Public Sub Main() 'Create the connection to the ftp server Dim cm As ConnectionManager = Dts.Connections.Add("FTP") 'create the FTP object that sends the files and pass it the connection created above. Dim ftp As FtpClientConnection = New FtpClientConnection(cm.AcquireConnection(Nothing))
Try 'Set the properties like username & password cm.Properties("ServerName").SetValue(cm, "xxxxxx") cm.Properties("ServerUserName").SetValue(cm, "xxxxx") cm.Properties("ServerPassword").SetValue(cm, "xxxxx") cm.Properties("ServerPort").SetValue(cm, "21") cm.Properties("Timeout").SetValue(cm, "0") 'The 0 setting will make it not timeout cm.Properties("ChunkSize").SetValue(cm, "1000") '1000 kb cm.Properties("Retries").SetValue(cm, "1")
'Connects to the ftp server ftp.Connect()
'**************************************** ' Potrebbe servire in futuro la tengo '**************************************** ''Get file listing 'Dim fileNames() As String 'Dim folderNames() As String 'ftp.GetListing(folderNames, fileNames) ''ftp the files 'ftp.DeleteFiles(fileNames)
'Build a array of all the file names that is going to be FTP'ed (in this case only one file) Dim files(1) As String files(0) = "\manny-slaveappWorkFACT-FINDERa.txt" files(1) = "\manny-slaveappWorkFACT-FINDER.txt"
'ftp the file 'I found it by mistake by creating both the FTP connection and task in the SSIS package and it defaulted the remote path setting in the FTP task. 'ftp.SendFiles(files, "", True, False) ' the True makes it overwrite existing file and False is saying that it is not transferring ASCII ftp.Close() Dts.TaskResult = Dts.Results.Success
I am using a SSIS package to import the .xml data file from FTP location and process them into SQL Server DB by using Stored Procedures. I am using FTP Task to retrieve the file from FTP location but it only works when ever internet is available otherwise it fails, I placed this package as a SQL Server Agent Job. Can anybody tell me the way to check the CONNECTION before FTP Task start its process to avoid the errors???
Please see the error below which I get from SQL Server Agent:
"Description: Failed to decrypt protected XML node "DTSroperty" with error 0x80070002 "The system cannot find the file specified.". You may not be authorized to access this information. This error occurs when there is a cryptographic error. Verify that the correct key is available. End Error Error: 2007-12-19 04:00:03.66 Code: 0xC001602A Source: AA_Trans Connection manager "FTP Connection Manager" Description: An error occurred in the requested FTP operation. Detailed error description: The password was not allowed . End Error Error: 2007-12-19 04:00:03.67 Code: 0xC002918F Source: FTP AA Transactions Receive FTP Task Description: Unable to connect to FTP server using "FTP Connection Manag... The package execution fails"
I am working on a SSIS package which is using a Script task, now I have all the connection properties set up in the .NET script using connection strings, what do I need to do if I have to set this up using a config file or something else which is more secure (I dont want to leave the connection information in the script). Please Advice.
I have a simple SSIS package with three "Execute SQL Tasks". I am using ADO.Net Connection to execute SPs on a DB server.
When I execute this package It works fine. So far so good.
Now, I need to implement transation on this package. And problem starts now onwards. When I try to execute package after setting TransationOption = Required for the Sequence container which contains all the tasks, I get following error.
[Execute SQL Task] Error: Failed to acquire connection "NYCDB0008.Export". Connection may not be configured correctly or you may not have the right permissions on this connection.
"NYCDB0008.Export" is the name of the ADO.Net connection. I have been hunting for any solution but all in vain. I have tried changing all DTC settings on the dev as well as Database server.
Hi everyone Can any one help me I am using Tranfer databse object task when I am trying to run it its throwing exception can not send null value in login name????
Help anyone!! I fighting with the same error. I've tried all the suggestions on the web and more. Nothing seems to work. Has anyone found an answer from Microsoft?
Error: The Execute method on the task returned error code 0x80131500 (ERROR : errorCode=-1073548784 description=Executing the query "EXEC dbo.sp_grantdbaccess @loginame = N'sctcsssoadmin', @name_in_db = N'ssoadmin' " failed with the following error: "User, group, or role 'ssoadmin' already exists in the current database.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly. helpFile= helpContext=0 idofInterfaceWithError={8BDFE893-E9D8-4D23-9739-DA807BCDC2AC}). The Execute method must succeed, and indicate the result using an "out" parameter.
In my SSIS package, I have a backup database task. When I run the package with DestinationAutoFolderPath set to a folder ("Network Service" account has full permission on this folder) and DestinationCreationType set to Auto, the task works just fine creating a backup with its own name. (similar to database_date<count>).
But what I want is in my front-end I am allowing the user to specify the name of the backup file. So I want the task to create the backup file in the name I supply. I set the DestinationCreationType to manual and in the application code added the DestinationManualList with the path from the UI.
Now the pacakge runs fine but does not take any backup. There is no errors as well. If I set the FailPackageOnFailure and FailParentOnFailure to true, then I am getting the DTSExecResult.Failure but I am not getting the actual error from the backup database task.
I have a SSIS package that transfers a couple of tables from one database to another database on the same server. It works fine in most of the machines we tested with. However on one of the customer machines, it consistently fails with the error message, The Return value was unknown. The process exit code was -1073741795. The step failed.
This package runs as a scheduled job on the sql agent. When i did a sql profiler to see what is going on, i noticed that the last step before the bulk insert, it gets the collation and the schema id of the 2 tables. My guess is, it compares these values from the source and destination databases and makes sure everything is ok before copying.
On a machine where this works, it goes ahead with the the next step which is the bulk insert itself. Whereas on the machines where it doesn't work, it stops right after this step. i.e. it does not even bother to call the 'bulk insert' api. Which makes me think it is doing some kind of validation with these values and it is getting something that is not expected.
If the collation or the schema was an issue, why throw an 'return value unknown' error? Can the error be more specific? Any other possible reasons for such a behavior? Any clues?
Hi, I have a sendmail task in my ssis package. In the From field, if i hardcode my from and to address as user@company.com it works fine and mail is sent. But i want to read the from and to values from a database table. SO i defined the package level variables and getting the values into the variables. SO at From if i specify the variable name it gives a compiel time error"the address in th from line is mal formed. it is either missing @ character or not valid". how do i specify teh variable for from address? I feel, may be i can use expression, but i don't know how to do that. Can anyone help me with this?
I have built a package that firstly shrinks a database and then backs it up which is scheduled to run each day, but I would like to add a check (Check Database Integrity) in as the first task and if the Database checks out ok then continue on, if not send an email.
Now, I am unsure if the Check Database Integrity Task in SSIS actually returns the success or failure message back to the package that I am after. The SQL behind the task includes the NO_INFOMSGS option.
Can anyone advise if it is possible to have the status/integrity of the database returned to the SSIS task and to proceed based on the result?
I set up a basic Transfer Database task (online, copy) to copy a DB. It works great except for the fact that it isn't transferring the PK's and FK's. It also looks like it did not transfer the views. Any idea why? Anything else the Transfer Database task doesn't actually transfer?
The Database Trasnfer Task has failed with the following error......failed with the following error: "Invalid object name 'dbo.exampleViewName.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
I set up a task to do a transfer of a SQL 2000 db to SQL 2005 in Integration Services (selected my servers, dbs, and chose DatabaseOnline method). In debug mode it processes for a little while and finally errors with:
[2] Progress: Starting database transfer.. Step 1 out of 2 complete
Error: The Execute method on the task returned error code 0x80131500 (An exception occurred while executing a Transact-SQL statement.). The Execute method must succeed, and indicate the result using an "out" parameter.
Can't get over this error, and net searches reveal other postings similiar, but no answers.
SSIS database transfer task (with overwrite) from SQL 2k source to SQL 2k5 destination fails with:
Error: The Execute method on the task returned error code 0x80131500 (ERROR : errorCode=-1073548784 description=Executing the query "CREATE ROLE [RFRSH_USER] " failed with the following error: "User, group, or role 'RFRSH_USER' already exists in the current database.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly. helpFile= helpContext=0 idofInterfaceWithError={8BDFE893-E9D8-4D23-9739-DA807BCDC2AC}). The Execute method must succeed, and indicate the result using an "out" parameter.
The error seems the same regardless if the destination DB exists or not!
I'm a newbie to SSIS so this question may cause people to point and laugh. I apologise if that's the case.
I have a configuration database that holds connection details to a remote database. I want to use these connection details to dynamically create a new connection to some remote database.
I usually work in with C# where this would be simple but I can't find how to do this using SSIS.
I have found people using configuration files but as I already have my connection data in a table I don't really want to strip it out. (Also, is it a security risk to have database connection strings stored in a config file?)
I have been able to implement a custom script object to build the connection string and assign it to a user variable within the package but can't find any way to then use that variable to connect to the remote database.
I am trying to dynamically create the connection to a database within an SSIS package.
the requirement is to allow the user to pass through the database as a variable and that variable will dynamically create the connection string in the connection manager.
I have installed MS SQL Server 2005 and Service Pack 2 on a new Windows 32-bit environment. I also installed the 32-bit 10g client (the Administrator option). The tnsnames.ora file is configured properly and I can tnsping to the Oracle database without any issues. I have created a package in Visual Studio and it runs successfully when I execute the job manually. I saved the package to the MS SQL Server and when I log into Management Studio to create a job for this package, I receive the following error:
Message Executed as user: xxxSYSTEM. ...rsion 9.00.3042.00 for 32-bit Copyright (C) Microsoft Corp 1984-2005. All rights reserved. Started: 10:42:37 AM Error: 2007-10-10 10:42:37.28 Code: 0xC0202009 Source: x Connection manager "x.x" Description: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005. An OLE DB record is available. Source: "Microsoft OLE DB Provider for Oracle" Hresult: 0x80004005 Description: "Oracle client and networking components were not found. These components are supplied by Oracle Corporation and are part of the Oracle Version 7.3.3 or later client software installation. Provider is unable to function until these components are installed.". End Error Error: 2007-10-10 10:42:37.28 Code: 0xC020801C Source: Data Flow Task OLE DB Source [18] Description: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER. The AcquireConnection method ca... The package execution fa... The step failed.
I have created the package and logged into the server with the same ID to set up the job. And I have set the ProtectionLevel property to "Don't Save Sensitive Data" since I know this has been an issue in the past when I tried automating the job. I've four posts regarding this error message on the MSDN forums that aren't helpful at this moment - I'm hoping that someone will have found a solution since those posts. Any suggestions are welcomed.
I am trying to dynamically change my initial catalog in a SSIS project. Each day I get a snapshot of data from the production server. I am performing ETL on that database and loading it into my warehouse. I am trying to put something together so that each day I get the latest snapshot and if its newer then my most recent one I pass that new catalog into the connection manager. I can already run the sql script to compare the two catalogs but I can't populate the connection manager.
I am using the "Transfer SQL Server Objects Task" to copy some tables from database A to database B including data.
The tables, primary key constraints, Foreign key, data and all transfers nicely except for "DEFAULT CONSTRAINTS" on the tables.
I have failed to find any option in the "Transfer SQL Server Objects Task" task to explicitly say "copy default constraints". So I guess logically it should happen automatically but it doesn't. I hope it is not a bug :-)
In short, does the €œTransfer SQL Server Objects Task€? support distributed transactions?
In trying to use a €œTransfer SQL Server Objects Task€? in a container using a transaction on the container. The task is set to support the transaction. It is setup to copy table data from several tables from a non-domain server (sql server 2000) to a domain-based server (sql server 2005). I get an error stating, €œThis task can not participate in a transaction€?.
I am wondering if it means exactly what it says €“ this task in SSIS can€™t participate at all. Or does it mean that it won€™t in this scenario for some reason. I attempted a simple copy of data from mssql 2005 to mssql 2005 (same server) and the task still failed). MSDTC appears to be running properly on my machine and such (I can do a simple distributed transaction across linked server to the 2000 server in Query Analyzer (QA)). Also, MSDTC appears to be working on both servers with distributed transaction query tests in QA.
Here€™s the error info€¦
SSIS package "Development BusinessContacts and Products Migration.dtsx" starting. Information: 0x4001100A at Copy BusinessContacts Data: Starting distributed transaction for this container. Error: 0xC002F319 at Copy BusinessContacts database table data 1, Transfer SQL Server Objects Task: This task can not participate in a transaction. Task failed: Copy BusinessContacts database table data 1 Information: 0x4001100C at Copy BusinessContacts database table data 1: Aborting the current distributed transaction. Information: 0x4001100C at Copy BusinessContacts Data: Aborting the current distributed transaction. SSIS package "Development BusinessContacts and Products Migration.dtsx" finished: Failure. The program '[4700] Development BusinessContacts and Products Migration.dtsx: DTS' has exited with code 0 (0x0).
A common issue that I run across with clients is they want only want to process a file if it's finished transmitting to the server. This SQL Server 2005 task reads the properties of a file and writes the values to a series of variables. For example, you can use this task to determine if the file is in use (still be uploaded or written to) and then conditionally run the Data Flow task to load the file if it's not being used. You can also use it to determine when the file was created in order to determine if it must be archived.
Dts.Connections.Item("myADO.NET connection").AcquireConnection(Nothing)Dim conn As New SqlClient.SqlConnection(Dts.Connections.Item("myADO.NET connection").ConnectionString) conn.Open()
This seems silly, in that I'm not really using the same connection, but using the connection string of a connection that already exists. And, for my purposes, it's not working currently, because I've switched from Windows Authentication to SQL Auth... and the password isn't coming over in the ConnectionString property.How do I re-use the exact same ADO.NET connection I have in my connection manager in a script task? That's the recommended way to go, right?
I've created my own posting for this. The original post was here, I apologize: http://forums.microsoft.com/forums/ShowPost.aspx?PostID=2906512&SiteID=1
According to the poster it's not possible. But there has to be some way to do it? Reflection (don't know how)?
I need to get a reference to the task host in an SSIS Task component.
Basically the scenario is this:
I have a custom task I have created. However I would like to validate that the ExecValueVariable is infact a string variable during the validate event of the task. I know how to verify its a string variable. But I can't figure out how to read what the user selected (such as User::Myvariable). The only way I've been able to figure out how to do it, but it only works if you open my custom task UI.
What I did is this:
I've implemented IDtsTaskUI and during the initialize section I wrote:
Sub Initialize(ByVal taskHost As TaskHost, ByVal serviceProvider As IServiceProvider) Implements IDtsTaskUI.Initialize ' Store the TaskHost of the task. Me.taskHostValue = taskHost Dim myTask As CustomTask= CType(taskHost.InnerObject, CustomTask) myTask.myTaskHost = taskHost End Sub
My Task is named: CustomTask. I have a public variable in my task as follows:
Public NotInheritable Class CustomTask Inherits Task Implements IDTSComponentPersist Public myTaskHost As TaskHost = Nothing
Therefore I pass back the taskhost value to the CustomTask class, and voila I have it.
Problem is, this only works if the custom task calls the initialize method, and this only happens when you open the custom editor.
I then do the validation in my CustomTask class and it works fine, but myTaskHost is null/nothing until you actually open the custom task UI
Both the OLE DB Connection and ADO.Net Connection in SSIS Package does not remember password.
Im connecting to a SQL Server 2000 box using its sa password as test.
The SSIS package runs fine when you first set up the connection in bids
The bottom line is that SSIS keeps forgetting the password I feed into the two Connections that I'm using. I double-click a connection, type the password in, check "Save my password" and hit "OK" but the password disappears from there whenever I run the package or double-click the connection again.
is there any known workaround for this issue as I would like to schedule my SSIS package using a SSIS Step in a SQL Server 2005 Agent job.
the only thing I found when googling this error was link below but the workaround described here is a little harsh
I'm getting "Access denied" error when I try to connect to SSIS from my desktop (Database Engine is fine). I'm a member of sysadmin within SQL, as well as an administrator on the server. I don't have any problem when I log on to the server directly via Remote Desktop and open SSIS.
I went into the surface area config tool, and I see that Database Engine and Analysis Services both expand and have a sub tabs to enable Services and Remote Connections, but Integration Services does not expand to a Remote Connections option, just Services. We're running MSDN Enterprise edition.
Does it matter if all the SQL services are using "Local System" for the logon ? I use an administrative logon on my SQL2000 boxes, and was fiddling with them on the 2005 box yesterday, but it seemed to cause more problems, so they are all Local System for now.
Well, I'm been trying to resolve my problems through searching previous post, but I'm starting to go around in circles. This is what my problem is: Originally, I created a SSIS package using windows authentication. Once I completed the work, I wanted to change the connection to SQL Server authentication and use xml configuration for deployment.
First problem: I edit the xml file, but can't use the connection I double clicked the Connection Manager connection and changed the log on from Windows to SQL Server. Password would not save, so, I read about what most posts have been about and I can go into the SIS menu, choose Package Configurations and create a xml file with the name of my connection manager.
Then, I exit the package and go into the xml file and enter the password=XXXX; stuff right after the user Id. When I load the package, the connection does not load?? Shouldn't the package pick-up the password now that I have entered it? I used note pad to edit the xml. If I go into note pad, I can see the edit. If I use SSIS package config to view the file, I don't see the password. I'm also having sql agent task problems, but I think I will be able to solve this if I can get the package to run with the password in the design mode. Can anyone help me with this?
Problem: my FTP Connection Manager cannot connect to the FTP service specified in its configuration parameters. When I execute the FTP Task hooked to that connection manager I get the following error:
[FTP Task] Error: Unable to connect to FTP server using "FTP Connection Manager".
When I test the FTP service using FTP from a command prompt on the same workstation using the same parameters it connects just fine.
When I attempt to edit the settings in the FTP Connection Manager, the editor window pops up and then immediately disappears which is another problem. As I watch closely I can see that the username property is set to my domain login, not the value I typed in when I created it.
So I used the property sheet for the manager to set all the parameters correctly. However it still will not connect. Am I missing something? I've seen posts concerning issues connecting to UNIX/LINUX based FTP services. This particular service is hosted on a LINUX box. TIA.
When I try to create an SSIS package with an FTP task, it always fails to compile with the messages:
Error at Package: The connection "" is not found. This error is thrown by Connections collection when the specific connection element is not found. Error at FTP Task [FTP Task]: Connection manager "" can not be found. Error at FTP Task: There were errors during task validation. (Microsoft.DataTransformationServices.VsIntegration)
The item is marked with a circled-X. The tool-tip also agrees: The connection "" is not found.
Using my recreation steps below, I am setting up a connection manager, but it is never found at compile time.
1. Open BIDS, select a new Integration Services project. 2. Drag an FTP task from the toolbox to the Control Flow window. 3. Double-click the FTP task. 4. On the FTP Task Editor window, General page, pull down the FTPConnection property. 5. Select <New Connection...> 6. On the FTP Connection Manager Editor window, enter the servername, port, username and password. 7. Click "Test Connection" to verify connectivity. (It succeeds.) 8. Click OK on the FTP Connection Manager Editor window. 9. Click OK on the FTP Task Editor window.
I'm not using a configuration file or logging provider for this example. I have also installed SP2 + cumulative update 2.