I have a simple SSIS package. Extract data from database, load into an .xls file and then email to users using sp_send_dbmail task. I have few different reports I do this task for. Now the issue is that I need to add password to those files before sending to users. I can do this in two ways: password protect the template manually and load the file in SSIS OR load and password protect the file (both) in SSIS. SSIS has limitations where it cannot open protected file neither has any way to protect the file as a task. Here are the few ways I have research I can do this:
Excel Interop via Script Task: Upon a lot of research, I found its not the best practice as it causes a lot of server issues and requires licensing so i dropped this idea.
OpenXML via Script Task: It only works with .xlsx but I have .xls file and I can only use .xls
Excel Macros: I have created a Macro which perfectly protects a file but the issue arises on how to execute this. Upon research found out it can be executed using Interop.
Write a batch file that will execute Excel Macros: I haven't really found a solution on how to run them using batch file (if it is even possible)
Use PowerShell to protect the file and then execute them through Execute Process task in SSIS. I am not familiar with PowerShell but I have researching and saw it is possible.
I have done A LOT of research on it and I am unable to find a right solution. My knowledge is very limited to SQL. Any suggestion would be greatly appreciated, thanks!
Load the file normally then lock it using a powershell script or a macro (not sure if this is possible). Locking and unlocking are external to SSIS, so its best handled by some sort of scripting language such as powershell. Read this
Lock Unlock excel files using PS script
Related
I'm not new to Access, but am very new to VBA coding. Our management software is horrible, but it's the best that is available in the industry and I have created many many reports using Access, but have new problem now.
Attachments in the system are stored in one central location and then the file name stored in a SQL table. I have created queries to pull the full file path including the file name. Would it be possible to use some VBA coding to print all the existing PDFs in sequence from the paths returned in the query?
Thank you for any and all help!
Native VBA controls the collections of methods and attributes from Office.
An existent PDF is not the case (Access can create one or open, but not open and print).
To open a file with full path you will need to perform a select from table and perform a loop to shell open file, after that, sendkeys ^P.
But I strongly recomend to use another tool to do it, like Auto Hotkey or AutoIt.
I've been doing some porting of old SSIS packages from a legacy system into a new system. I was running some tests only to see some kind of error output related to the ODBC connection with Code: 0xC0202009.
The package's two connection managers are both built with SQLNCLI11.1 as the provider.
I believe I can fix the error if I switch that to SQLOLEDB.1. Is there a simple way to do that without having to rebuild the entire package from scratch? Is there an XML file somewhere I can just replace the old value with the new one?
The only way is to open the package (.dtsx) file with a text editor (notepad, notepad++). And search for this property and replace it manually. (.Dtsx file is an xml file)
But replacing this property may cause other errors if each provider has different properties. So Take a backup of these packages before editing.
Take a look at this question it may help you (check my answer and the others. It will give you an idea on how a dtsx file can be readed outside of visual studio):
Automate Version number Retrieval from .Dtsx files
I am working with SharePoint 2010. I need to get the data from excel file stored in sharepoint library. I have plans to accomplish this by using OLEDB connection. So I need to download the excel file from doc library and store it in a temporary location and then access this temp file to get data from it. Now my question is which is the best ans safe location to stored the downloaded file? So far I have used SharePoint's layouts directory, C:windows:TEMP and even Path.GetTempFileName(). But the result I get this is " ACCESS DENIED!". Any ideas in temporary location? Is there any other location which is safe?
Thanks
Check whether you are running the file saving code with Run with elevated privileges and the app pool account has write access to the provided path. It's not a good practice to store temp files inside 14 hive.
Why don't you use Excel Web services to read the excel file if your farm has excel services enabled.
Refer http://msdn.microsoft.com/en-us/library/ms500767%28v=office.14%29.aspx
Or else try to use third party libraries like EPPlus where you can open the excel file using a stream rather than from a physical file location.
Need to upload excel file using Script task in SSIS 2005. Can someone please help, provide the code.
Regards
I always use OLEDB for this and I answered this recently with a code sample here...
Best fastest way to read an excel sheet
I've always found it the best way, mainly because using a data flow task with an Excel Source doesn't allow you to either vary the Excel or to validate it's contents.
How to edit a Word Document (.docx) stored in a SQL Server Table?
Here is the tentative work flow:
Read BLOB from SQL Table through Ideablade
Write BLOB to disk as .docx
Open .docx using Word
User makes changes
Save .docx using Word
Read .docx into BLOB
Write BLOB back to SQL Table through Ideablade
All sample code is welcomed?
I am sure there are a lot of people doing this already.
Any other ideas on how to simplify this process?
I am using VB.NET, .NET 3.5 SP1, WinForm and SQL Server 2008.
Well, as to the how, here is how to read a blob and write a blob to SQL. Although frankly, unless you have very good reasons such as an existing backup system, you would probably be best served storing the file to the file system and the path and metadata in the database. Either way, abstract it in your BLL, so you can change your mind down the road.
Retrieving and updating the BLOB from the db shouldn't be a problem, you'll find lots of sample code to do that on the net.
A simple approach to your problem would be to create a "temp" or "working" directory somewhere and monitor it with System.IO.FileSystemWatcher (sample code). When the user wants to edit a file, fetch it from the db and store it the directory. Whenever the user saves the file, you'll get a notification from your FileSystemWatcher, so you can save it to the database. Don't forget to empty the directory from time to time.
The method I've seen for this that I think works best is to build this as an add-on for MS Word itself. Examples include the Save to Sharepoint, Save to Moodle, and other similar add-ins.