SSRS - can connect two datasets but not three - sql-server

I'm making my first report with Sql Server Reporting Services (2012) and have managed to create two datasets successfully, each one connecting to the same Data Source. This Data source uses an embedded connection and the user can select the server and Database at runtime. The connection string is as follows
="data source=" & Parameters!ServerName.Value & ";initial catalog=" & Parameters!DatabaseName.Value
The two parameters in question are created and everything works fine for these two datasets, the report displays with a choice of servers and databases and displays the relevant data when I click on Show Report.
However, when I try to add a third DataSet (I need a separate SQL command to pull separate data for the footer and header) this one doesn't connect.
I've tried the following:
-Right click on the existing data source to create the data set, selecting the existing source. When I open the query designer it fails to connect
-Create a new data source with a fixed connection string. This works but is not what I want
-Create a new data source with another name and the same connection string as the original. This fails, and is not really what I want anyway.
Is there anything obvious I'm overlooking? For info, I originally had the first two data sets created and running with a fixed connection string before I changed the connection string in the data source to use a dynamic one. I've restarted the report designer since, though, and the first data sets continue to connect using the dynamic string. I tested with multiple databases just to be sure

Never done this before myself but the last 2 sentences in the section Expression-Based connection Strings msdn.microsoft.com/en-us/library/… looks to me like you need to revert to a fixed connection string to do your update then change back to dynamic when ready to publish?

Related

How to avoid prompting for user id and password in MSAccess 2003

I am a .Net / SQL Server programmer. I am trying to make an Access database created by someone else to work. It looks like is uses a procedure similar to Save password for ODBC connection to SQL Server from MS Access 2007 but I am using Access 2003 so I suspect something else needs to be done. I don't really know what I am doing with Access but I am stuck with it.
I do have an ODBC connection and it looks like the linked tables use it. The database has an AutoExec which populates some local tables from the linked tables that the reports use. It also calls a qryConnect with a dsn-less connection like the linked article and this seems to work. I have got it to stop asking for a user and password on start up. I can also open most reports without problems, 2 do not work. A form loads on Startup with buttons that basically show reports. This is where it gets odd.
The reports fail from the ODBC driver with the windows credentials. Then a logon box shows up with the correct user (a user with read only privileges) but the trusted connection box is checked. I do not have the trusted box checked in the DSN. Not do I have Trusted_Connection=Yes in the DSN-less connection in qryConnect.
This is the code in the form
stDocName = "rptNegativeLotQtys"
DoCmd.OpenReport stDocName, acPreview
I don't know how I buggered it up so much and before I try again copying everything to a new mdb and trying again I am hoping to get some guidance.
On a side note I can open everything fine on my machine. I am an administrator as far as Windows is concerned but not SQL Server.
EDIT:
I created a new DSN just for these reports. Then I deleted all linked tables and re-linked then using the new DSN. I looked at the linked tables in MsysObjects and the new DSN is listed there. Yet Access still prompts for the password. It appears that it is not caching the password.
Actually, you do NOT need to add nor store the UID/Pass in the connection strings used. However, what you MUST ensure is that all connection strings are the SAME. If they are different, then the cached UID/password will not work.
Also, make sure you do NOT connect nor open a table AFTER having connected using Windows Auth – the reason being then when you add the table links (especially via code), then the cached setup of using windows auth will occur, and thus prompts will occur when the links suggest to do otherwise. In other words linking and attempted to use SQL logons will NOT work if you already opened any table link via windows auth (so exit the database and do NOT open any table that could/can use windows auth).
So I would delete the links, and re-create them – but again, ensure that you never connected as a windows auth user to SQL server.
So the "cache" that access has is a GREAT friend/feature to eliminate the need to include UID/pass in the connection string - but the SAME feature will bite you VERY bad if you at any time connecte to the database in question via windows auth.
How to “cache” the user logon and ID is explained here:
Power Tip: Improve the security of database connections
http://blogs.office.com/b/microsoft-access/archive/2011/04/08/power-tip-improve-the-security-of-database-connections.aspx
So you “can” include the UID/LOGON in the linked tables, but above shows that a ONE time logon can also be used. So be VERY careful when setting up table links – due to the above “cache” of the user and HOW they logged into the database – code that ATTEMPTS to create table links based SQL logons will actually wind up using windows auth if you already connected as such (so exit the database if you going to re-link using SQL logons).
Keep in mind, Access does NOT use the DSN AFTER you linked the table. The information from the DSN is a ONE TIME copy to the connection string. You can verify this by going into my documents and deleting the DSN you used. Assuming the linked table was working correctly, you find that they CONTINUE to work EVEN if you delete the DSN. In effect this means that linked tables are DSN less except for when you create the linked table. This allows you to easy copy the application to different computers without having to copy the DSN.
As to ensure that all the linked tables use the same connection string, it is a simple matter to delete them all, and re-link.
You can also hit ctrl-g to bring up the debug window, and look at the connection string this way:
? currentdb.TableDefs("linked table name").Connect
the result in the debug window for a windows auth connection string will look like this:
ODBC;Description=test DSN;DRIVER=SQL Server;
SERVER=albertkallal-pc\SQLEXPRESS;
Trusted_Connection=Yes;
APP=Microsoft Office 2010;DATABASE=AxisMIS
Note how in above we see "trusted connection" (that means windows auth).
If I linked the table using SQL logon (and REMEMBER to check save password), then you see this:
ODBC;Description=TEST3;DRIVER=SQL Server;
SERVER=ALBERTKALLAL-PC\SQLEXPRESS;
UID=MySQLogon;PWD=MyPassword;
APP=Microsoft Office 2010;DATABASE=AxisMIS
Just remember during the table link process to "check" the save password.
eg this:

Dynamic datasource in SSRS

I am working on a report which will pull all sysadmin login's from each server. So I used below data source properties and created parameter names:
servername ="data source=" & Parameters!Servername.Value & ";initial catalog= master"
above solution working fine in SQL Server Data tools but when I deploy in report server I am getting error on connection error's like below.
An error has occurred during report processing. (rsProcessingAborted)
Cannot create a connection to data source 'dSource_DbOwner'.
(rsErrorOpeningConnection) Format of the initialization string does
not conform to specification starting at index 0.
Please let me know all your inputs
Thanks, Ven
SSRS can be annoying sometimes with plain text. I would suggest going into the connection manager and using the wizard. I believe it is a button with build on it to the top right hand side of where you are inputing this text. That will create the connection easily and it wont spit and sputter at the connection string.

Using Excel to connect different SQL Server instances (Environments)

I have an Excel workbook which is used for data reconciliation from SQL server. There are 3 different environments which I need to reconcile data.
I have a stored procedure which pulls the specific data, Currently my "DATA CONNECTION" is pointing to a TEST Environment. However I need to be able to dynamically change my environment between TEST, UAT, PROD AND DEV.
Can anybody please help me out ?
In Data > Connections you can see and change your connections.
If you saved your Data Connection to a file (odc) then you can just switch the Connection file in the Connection Properties > Definition. Otherwise, you can change the Connection string itself.

Using Dynamic Connection Strings in SSRS2008

I have a bunch of SSRS 2008 reports which I'd like to run on several different machines (development, test, production). Each machine has it's own database, so I need to use different connection strings depending on where the report is running.
One workaround I found is to specify the server and catalog name in a hidden parameter that is passed to the report at runtime. It's described in this tutorial, but it applies to SSRS 2005 and I could not make it work in SSRS 2008.
Everything works fine when the connection string in my shared datasource looks like this:
Just so to see if expressions can be used at all for the connection string, I replaced the connection string with this:
But this gives me the following error when I try to preview the report in Visual Studio:
An error occurred during local report
processing. The item
'/Zeiterfassung-Adrian' cannot be
found.
Are dynamic connection strings still working in SSRS 2008?
If yes, what am I doing wrong?
If not, what else can I do?
It's because it's a shared datasource. Should work fine for a regular embedded datasource. Take a look at THIS link for an option on using dynamic connections strings with shared datasources, might be helpful for you.
Just create your report datasource for each environment and deploy them. Then switch your deploy option to not overwrite a datasource. Though to make for simple deployments you will have to configure the configuration manager in bids for each environment. This is how we work in our multiple environments.
Hope it helps, let me know if you have any questions on this.
Please check related article at
http://haseebmukhtar.wordpress.com/2011/11/09/dynamic-database-in-ssrs-2008/
Also you can not use dynamic database settings for the shared data source.
The string should have double double quotes for server name.
="data source="" & Parameters!MyServerParameter.Value & "";initial catalog=DBName.."
I was able to create a dynamic embedded connection using a ServerName parameter as follows:
="data source=" & Parameters!ServerName.Value & ";initial catalog=master"
What about using a hidden report parameter?
then you should be able to do:
="data source=" & Parameters!MyServerParameter.Value & ";initial catalog=DBName.."
Here is an article which should help you out: http://msdn.microsoft.com/en-us/library/ms156450.aspx

Reporting Services, how to use a connection string from a query result

A report needs to be run on multiple sites, each with its own connection string. These site names and connection strings are stored centrally.
I want to make a report that
Accepts the site name as a parameter
Queries for the sites connection string
Uses the sites connection string to get the report's data
I've tried using two data sources in the report, where the first data source uses the site name parameter to retrieve the connection string and the second uses an 'embedded connection' with a function for its connection string.
=First(Fields!ConnectionString.Value, "SiteDetails")
However when I run the report I get:
[rsFieldInQueryParameterExpression] The expression used for the parameter ‘SiteDataSource’ in the dataset ‘SiteDataSource’ refers to a field. Fields cannot be used in query parameter expressions.
Is there a way around this, to use a connection string from a database?
I am using SQL Server 2008 Reporting Services.
I have had this working in SSRS 2005 by storing the connection string in a hidden report parameter, then setting the connection string of the second query using that parameter.
I wrote a blog post about something similar a while ago, you might find it usefull - http://www.beakersoft.co.uk/2008/06/22/setting-a-data-source-at-runtime-on-sql-reporting-services/

Resources