How to set SSIS Http Connection Manager credentials with config file? - sql-server-2005

Within an SSIS package I have a Web Service task which uses an Http Connection Manager. I need to set credentials for the connection so that it will authenticate with the remote web service. I can set these at design time, however I would like these credentials to be provided to the package using an XML package configuration file.
The problem is that the credentials for the connection do not appear among the properties that can be configured. I have tried setting this programmatically, but I cannot seem to access the credentials that way either:
Dim webConnMgr As ConnectionManager = Dts.Connections("My web service")
Dim webConn As Wrapper.ConnectionManagerHttpClass = _
CType(webConnMgr.InnerObject, Wrapper.ConnectionManagerHttpClass)
webConn.?
Any ideas?

SQL 2005 has very limited member properties for the ConnectionManagerHttpClass. Thankfully it has been addressed in SQL 2008 :)
MSDN - SQL 2005 ConnectionManagerHttpClass properties.
VS.
MSDN - SQL 2008 ConnectionManagerHttpClass properties.
According to this MSDN link, the public class [ConnectionManagerHttpClass] implements IDTSConnectionManager90, ConnectionManagerHttp.
Since we will assume you are using SQL 2005 (according to your Stackoverflow tags), you may want to check out the IDTSConnectionManager90.ConnectionString Property on MSDN as well.
Also check out the ConnectionManagerHttpClass.ConnectionString Property on MSDN, which implements IDTSConnectionManager90.ConnectionString and is overridable.
This should point you into the right direction. May the farce be with you.

Sounds like you need to assign the values in the configuration file to a variable in your package. You can then access the variable from your script task (Dts.Variables("VariableName").Value.ToString if I remember rightly!).

I have found no way to specify the credentials using a configuration file, or programmatically, but a workaround is to simply save all the credentials (as set in the designer) in the package, and then have different copies of the package for each different configuration. This is done by setting the ProtectionLevel of the package to, for example, EncryptSensitiveWithPassword.
This is obviously not ideal.

SQL2008 SSIS exposes these properties correctly; unfortunately 2005 is the environment I have to work with. I have worked around the problem by developing a custom component which allows the properties to be set.

this can be done by setting protection level to EncryptSensitiveWithPassword, and run the ssis with decrypt option

Related

How to fix "login failed for user" when manipulating SQL database in Azure from a .NET Core webapp?

I have an SQL Database in Azure and a .Net Core web app in which I would like to manipulate the database using Entity Framework Core.
I believe I have all the model, data and controller classes needed for this, and I have a few sample objects I'd like to see in my database.
My problem is that no matter what I do or how I want to manipulate the database, I always get the error "login failed for user", yet the login info is an admin and I believe I set up everything that is needed.
I see the database in the SQL Server Object Explorer, I can connect to it using SSMS or simply on the Azure Portal, and there seems to be no problem with my connection string. The username&password combo is fine, I've checked it multiple times, my IP is enabled in the firewall of the database, I have no idea what could be the problem, please help me!
Here is the error:
The problem is solved now, it was a very tiny, stupid error:
the connection string I copied from the Azure site was waiting for an escaped field, assuming I won't write my username and password manually, which of course won't be happening in the future, I just wanted to test if the whole stuff worked as this is my first project in this area.
So the Azure connection string looked like this: USER={XY};PASSWORD={ASD} but I left the curly brackets in the string even though I didn't use a variable there.
I test and it works fine. So I am doubt about whether you could run it in local with the connectionstring of Azure sql database.
Open your azure sql server on portal and click your sql database.
Click the Connection string and copy the connectionstring. Filled into your username and password.
Then put it to the connection string in appsettings.json on visual studio.
If you could run on local, then you publish will have no problem.
Also, you could follow this article to learn with asp.net core mvc.

Encrypt query string in SQL possible?

please give me some advice. I have to send email using SQL database mail. In my email, I have to create links that a user can click to go to a product page on my site. However, I need to encrypt the ID of the product and once the product page load, the querystring of the product ID will be decrypted.
How can I get the encryption algorithm which I created in web site class into SQL? I believe the decryption and encryption algorithm must be the same, so that my page can decrypt correctly when the user click on the link in their email. The encryption class I use is something similar to this link: http://www.codeproject.com/Articles/33350/Encrypting-Query-Strings
Thanks a lot for your help.
PS: I also posted this question on asp.net forum.
You can run CLR (ie .NET) code within SQL Server. There are several steps involved, but it starts with creating an "SQL Server" project within Visual Studio, writing the code, and deploying it to your SQL Server. You also have to enable CLR functions within SQL Server using sp_configure.
See here (MSDN) for detailed instructions: How to: Create and Run a CLR SQL Server User-Defined Function .
After doing quite some research, I can confirm that CLR is the way to go. As suggested, I used user defined function CLR. First I need to create CLR project in visual studio. Here is a good starting point to understand how it works:
http://blog.sqlauthority.com/2008/10/19/sql-server-introduction-to-clr-simple-example-of-clr-stored-procedure/
Then instead of adding a CLR stored procedure I move to User defined function. Add an encryption class and called the class in the user defined function. Build and Deploy. That's it.
Here is another useful links:
http://channel9.msdn.com/Learn/Courses/SQL2008R2TrainingKit/CLR/CLRIntegrationLab/Exercise-1-Creating-User-Defined-Functions-Using-SQL-CLR
Thanks dbaseman for pointing that out.

How to set database name as a variable in SSIS?

In my current project, the database name keeps changing and I do not want to modify my OLE DB Sources each time. Thus I want to set it as a variable. That is, in each OLE DB Source, I could use it as a parameter. However, it seems SSIS doesn't allow database name to be transferred as a parameter. So what should I do to minimize my changes?
I wish to do something like this SQL statement in OLE DB Source:
Select OrderID
From ?.Order
And I just need to modify my variable when the database name is changed.
Thanks for any solutions!
you need to add package configurations to your package and set the database name of the connection manager as one of the configurations
Just right click any blank area on the control flow and select "package configuration" and follow the wizard.
I Suggest you start with a XML configuration because its easier to understand.
A couple of suggestions for you:
http://social.msdn.microsoft.com/Forums/en-us/sqlintegrationservices/thread/586bf0a7-16c1-4a24-a9b2-7b8fb0cffda9
http://social.msdn.microsoft.com/forums/en-US/sqlintegrationservices/thread/b72e1b45-9a78-4865-912a-4587fa72c7f7
I like to manage Server\Instance.Database at the connection manager and Schema.Table or View at the task or adapter level. I recommend externalizing connection manager connection strings. You can use Package Configurations to do this, or you can manage it yourself (I use a table with ConnectionName and ConnectionString columns, and encrypt the ConnectionString column). In my opinion, a hard-coded database name inside an SSIS package is not a best practice.
I recently recorded a couple sessions on SSIS Connections management - one for 2005, 2008, and 2008 R2; another for 2012. I have also recorded a session on managing configurations in SSIS (although the audio is poor).
I hope these help.
Andy
Check out this terrific post on how to parameterize the database name. This a very thorough blog post on the topic of parameters and environments in SSIS.
http://www.sqlchick.com/entries/2015/1/4/parameterizing-connections-and-values-at-runtime-using-ssis-environment-variables

Reading data from a remote database

How to read data, submit queries from vb application to a remote machine running sql server.
Please note: I have created a complete functional version of a stock control system with the database residing in the local machine. I just need the basic concept of interacting with remote databases that's all. Do we have to use sockets to read/send data ?
All you need to do is change your connection string to the remote db server and make sure that the server is actually listening. (Link assumes 2005 but 2k, 2k8+ config will be similar and easily Googled for...) You definitely DO NOT have to write special code for this.
Check out http://connectionstrings.com/ for a handy reference for the different types of connection strings in different situations.
Are we talk about .NET version of VB or old fashioned VB 6?
In .NET version of VB (VB.NET) you can use OLEDB Data adapter, ODBC Data Adapter or native .NET Data adapter depends on your needs.
See MSDN documentation enter link description here
In VB6 version, you can use ADO, OLEDB or ODBC. See documentation here: http://msdn.microsoft.com/en-us/library/aa968814(v=vs.85).aspx
I don;t recommendate to connect your application via socket by yourself because this is really bloody coding.

How can I fix LINQ dependency issues with a VB.NET deployment?

I have a program that contains .dbml files. I created this file with Server Explorer.
I want to execute this program on other computers but I seem to be having issues with dependencies because I use LINQ.
How can I fix this?
Can you be more specific? What errors are you encountering? Did you use SQL Passwords or Network authentication? Do your users have network accounts added to SQL? Is this a permission based error?
Just one other possibility: Your users should have .NET 3.51 installed on their systems or they won't get the best possible Linq support. They might not have the Linq assemblies at all.
Yeah, we need more info, but I'm guessing you're having problems with the ConnectionString? as in, there's a connection string in your DBML designer file, and it doesn't match your production DB connection string?
If this is the case, then perhaps write a class that handles all instantiations of your DataContext in your code.
Then, within that class, whenever a new datacontext is created, you override the DBML connectionstring with your current connectionstring, probably from your web.config. this ensures your LINQ stuff is always connected to the correct DB during runtime.
Perhaps something like this (the property names might differ):
Public Shared Function GetNewContext() As YourDataContext
Dim dContext As YourDataContext
dContext = New YourDataContext()
dContext.Connection.ConnectionString = MyConnectionStringFromTheWebConfig()
Return dContext
End Function