Dynamically Change the Datasource in Sql Reporting Serivces 2008 - sql-server-2008

I want to use the same Reports(.rdl) to generate the reports for 24 databases.
For instance if there is a user table in my reports(.rdl), then the datasource for the report(.rdl) should change dynamically. Now, I'm making 24 different Reports for 24 databases.
I want a single report(.rdl) with the datasource changed at the runtime.

The way to achieve this could be adding 3 parameters to your report (.rdl) file
ServerName
DatabaseName
and if required
Password
Then change the connection string for the datasource like
="data source=" & Parameters!ServerName.Value & ";initial catalog=" & Parameters!DatabaseName.Value
Only small issue with this approach is the paramnames are visible in the URI so caveat emptor

I found an alternative solution to my problem. I created a single (.rdl) Report file which used the user which had a right in all the databases gave the datasource as this user, and the database as in which I made single procedure in a database, suppose admin database(used for all procedure which are common to all), In that procedure I executed the procedure which is present in other databases like this:
set #sSql='Execute '+ #databasename + '.'+ #username + '.'+'GetData'
EXEC (#sSql)
where username and Databasename are present in the table(for all database) and a column name sentDate which is update to todays date after executing the procedure for that databaseName, so that the datasource moves to next after username and databasename after executing the procedure. And made the subscription to run after 10 min, so that it can send the reports of all databases, by getting data form different database in each execution.

Related

how to create ssrs report that shows database names as a dropdown filter and user can select the database dynamically and run the report

how to create ssrs report that shows database names as a dropdown filter and user can select the database name and connect dynamically and run the report.
The Server name is same, just the databases must by dynamic.
Please let me know.
You need to create a datasource in your report, this will not work on a shared datasource.
Create a new datasource and then next to the connection string field, click the fx button. You can build your connection string using parameter values to change the database. The expression might look something like this..
="Data Source=MyServerName;Initial Catalog=" & Parameters!myDatabaseParameter.Value & ";Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"

SSRS how to access Shared DataSet values in expression

I need to set the connection string somewhere in one place in SSRS project in order to use it in Data Sources across all the reports. As SSRS doesn't support project params it's recommended to create Shared DataSet instead, e. g. HostParam.rds
SELECT 'localhost' AS GlobalParameter
The question is how to access it further in expression in Data Source connection string
="Data Source=" + HostParam.GlobalParameter + ";Initial Catalog=xxx"
gives an error 'HostParam' is not declared
You can setup a shared datasource at the project level, this contains just the connection to the database.
You then select this shared datasource when creating datasets (this works for both shared datasets or embedded datasets).
If you change the connection in the shared data source, this is reflected in all the datasets and therefore reports that reference it.

SSRS Report Switch Datasource

I am using SSRS reports and now I want to change data-source base on parameter. I had all ready tried to create a dynamic data source base on parameter and it works perfect on our local environment. But on production we are not able connect database due to security issue.
To overcome the security issue. we had created two data source "ProdDB" and "ArchDB" in reporting server and map with my report's data source
Now I want to know how we can Switch data source base on parameter like
Report parameter #dbsource = "Prod"
if #dbsource.value = "Prod" then
datasource = "ProdDB
Else
DataSource = "ArchDB"
Here is what you can do
Create two report parameters as databaseName and DatabaseServer
in datasource-> properties -> connection String -> expression write a connection string as below
="Data Source=" + Parameters!databaseServer.Value + ";Initial Catalog=" + Parameters!databaseName.Value
This will ask database name and database server as a report parameters, if you are running the report as data driven subscriptions you can pass these parameters dynamically from a query or static subscription parameters.

Can I use a persistent (Oracle) recordset in access project?

Obviously you cannot set the recordset property of a form in an Access Project with an Oracle-based recordset, but is there a way to show or select these records in an Access form?
Add a DSN entry for the Oracle database in the ODBC control panel
In Access, create a new Query, define it as Pass-Through, type whatever you want in the query text otherwise you can't save it (SELECT * is ok). This pass-trough query will be used to retrieve data from Oracle and show them in your form, and you will define it's SQL on-the-fly in the VBA code
In your form code, do this:
' Add this local variable to your form
Private OracleQD As QueryDef
' Do the following in the Load event of your form :
Set OracleQD = CurrentDb.QueryDefs("Your_Previously_Created_Query_name")
OracleQD.Connect = "ODBC;DSN=your_ODBC_entry_name;UID=your_Oracle_User;Pwd=Your_Oracle_Password"
OracleQD.ODBCTimeout = 600 ' Set to anything you want
' Do this everytime you want to retrieve data from Oracle
OracleQD.SQL = "SELECT * FROM whatever_table_you_want"
Set Form_Your_form_name.Recordset = OracleQD.OpenRecordset(dbOpenSnapshot)
I solved the problem by creating a table on the back-end server, looping through the oracle-based recordset in VBA and then creating new records in the (sql server) table by using a stored procedure which takes fields from the oracle-based recordset as parameters and inserts these values as a record in the sql server table.

Creating a VB script to write to an SQL database

At the moment, I have set up an SQL database with one table with various fields.
I have not done VB scripts before and at the moment i have in my script
objConnection.Open _
"Provider=SQLOLEDB;" & _
"Data Source=atl-sql-01;" & _
"Trusted_Connection=Yes;" & _ "InitialCatalog=SCM-69462\SQLEXPRESS;" &
my InitialCatlog= I have entered the server which the database is on. This server has many different databases on already (from different students). I have set up a database X and created a table within this database. A basic table with 4 fields. With the intialCatalog string, will this locate the specific database on the server or do I need some more information? Or would I simple put "InitialCatalog=x" & x being the database name on the server, not the server itself?.
According to THE authority the connection string should look like:
Provider=sqloledb;Data Source=myServerAddress;Initial Catalog=myDataBase;
Integrated Security=SSPI;
so try:
Provider=sqloledb;Data Source=SCM-69462\SQLEXPRESS;Initial Catalog=X;
Integrated Security=SSPI;
Then test, whether adding "Trusted_Connection=Yes" helps.