Programmatically change crystal rpt connection - string

I'm trying to find a way to Programmatically change the connection string of an rpt file permanently to a connection that currently doesn't exist. I need to send these rpt reports out to clients who are using a different connection then I am.
I've tried some examples where you load the report and then set the connection with apply logon info, but it seemed to only affect the report at run time and the changes never stayed. I need the rpt file to keep the connection string i set.
Is there an way to do this?

You need to call the method SaveAs of the ReportDocument class.
If you need to change just one file you can use this tool instead of writing your own code: http://www.r-tag.com/Pages/CRDataSource.aspx
The free version works for one file without restrictions.

Related

How do I 'trust' an external data source in Excel?

I have a tool that uses an external data connection to keep a dashboard updated from single CSV which contains a data log. I don't want anyone touching the log itself and fiddling with it, so I have put together a small dashboard that is fed from the data displayed by the connection.
I have the connection set to update on open and every 10 minutes in the background, but it does not do this. Instead, I need to manually press refresh, whereupon I get the following message:
'Microsoft Office has ifentified a potential security concern' message box example
I absolutely trust the source in question, but do not want my user to have to click refresh every now and then to make sure their data is up to date.
How can I make this connection 'trusted' and have this persist through sessions?
(Apologies if I have missed anything or this isn't the right way to ask this question. I'm new! :) )
Moved the tool and it's peripherals to a (trusted) shared drive, and no problems.

Can't refresh external connection in Excel from Mac

I have an Excel workbook that has several External data connections via PowerQuery (actually from built-in Data > Get External Data, and slightly modified code in PowerQuery to include variable filenames). The connections are made to .xslx, .xlsm and .csv files.
As I read, Microsoft states that it is possible to refresh existing connections on Mac, that are made to these types of files (not sure about .xlsm, but probably that does not matter, as not a single connection refreshes). However, when I try to refresh a query, it throws an error:
[Expression.Error] The module named 'ExcelInterop' has been disabled in this context.
At first, I thought it was a connection to Named Table in the current workbook (as I read on Microsoft, it is not supported in Mac), but even when I removed it, the problem persisted. There is not really much information on Google on this issue, so I post it here. Is there a way to actually refresh the data on Mac or no? Thanks to all.

Excel ,VBA, PowerPivot, DataFeed connection - update path to file

I am trying to preapare excel file which would download data from many sources with one button.
Sadly, this file would be used by people, which have not any shared folder or something, i cant connect datafeed file in place where they all can access it.
This connection is created in PowerPivot.
Thats why i am trying to prepare macro, which would update path to file for each user.
How i can update this path with vba?
I am able to get current path by using
Debug.print Activeworkbook.Connections(1).Datafeedconnection.Connection
But i cant update this which using
Activeworkbook.Connections(1).Datafeedconnection.Connection = "..."
It dont work with puting the result of debug.print with small changes, also it dont work when i am trying set this connection to something like = "Test"
If it's needed, i would give exact result of debug.print when i get access to this file (probably tomorrow), but maybe if i am doing something wrong (like choosing wrong command), you can help me before that?
With little help from another place i found solution for this problem.
When i am creating connection with PowerPivot, i am not able to edit datefeedconnection.connection property (it returns error 1004).
However, when the connection is created in excel directly i am able to update this by command:
Activeworkbook.Connections(1).Datafeedconnection.Connection = "..."
To create connection in excel directly, we have to go into:
- Data tab
- Existing connnection
- Browse for more (bottom left corner of box)
- Choose your .atomsvc file

How can ADO.NET read a locked Excel file?

ADO.NET works fine when it comes to reading tabular data from excel files, but one problem I often run into is that if the excel file is locked by some other user there is an exception when ADO.NET attempts to retrieve the data.
Is it possible to tell ADO.NET to read contents from the excel file even if it's locked? If so, how can it be done? Do I need to add something to the connection string? The extended properties of my connection string are:
Excel 12.0;HDR=YES;IMEX=1
I had similar problem and I could not find a solution. I ended it up with timer re-trying to connect to a file.
The problem lies in the database itself. In the end of the day it is only a flat file and ADO requires exclusive access to it. You probably need to migrate your solution to MS Access mdb file or a proper(ish) database (SQLite?)

SSIS with variable excel connection manager

I am trying to do automatic package execution with a WMI Event Watcher Task within SSIS. The functionality I want is automatic package execution when excel files are dropped into a certain folder. However, these excel files will be the connection managers for populating a database.
Currently SSIS will not allow me to do this because my excel connection manager does not have a path when I run the program, and only exists once the files are dropped in the folder.
Is there a way for variable excel connection managers or the value of the connection string to be a variable?
Also, how do I implement the usage of this variable in an expression?
You can use a variable for the connection string of you excel source:
Click on your Connection manager of your excel source
In properties window, add an expression(1) ConnectionString(2) and assign a variable(3)
There are alot of different things you can do with variables. They are used alot in combination with for each loop containers and file system tasks. Your normally do something like this
create a variable in variable window
Set a static value or one that gets changed during the package flow
Map the variable to an expression
There are alot howtos on the web, maybe have a look at this to get warm with it:
http://www.simple-talk.com/sql/ssis/working-with-variables-in-sql-server-integration-services/
http://www.rafael-salas.com/2007/03/ssis-file-system-task-move-and-rename.html
The fastest way i know to achieve this is by creating an excel connection manager and setting its connection string through a variable. In order to do so you will need to make the connector first by pointing it to an excel file. It doesn't matter which, since you will be dynamically setting the new file in runtime. Then, select your excel connection manager and check its properties. You have a ConnectionString property, which you can set through an expression.
However, you must make sure that your package will only use the Excel Connector after it has been filled with the correct connection string!
For further information on SSIS variables check this link: Variables in SSIS

Resources