SQL Reporting Services DataConnection Update - sql-server

Is it possible to change the connection string of a published sql reporting services report? I can see the binary field called DataSource in the ReportServer database, but since it's stored as binary I don't think it's easily updatable.
Do I need to republish the report with the correct data source? I'm hoping not since I do not want to have to install VS2003.
EDIT: The client is running SQL Server 2000 Reporting Services with all of the service packs installed.

SQL Reporting Services 2000 has a [web service](http://msdn.microsoft.com/en-us/library/aa274396(SQL.80).aspx) that you can use to change the data source. Given that, the following, allows for changing of a data source to a shared data source. This was [adapted from MSDN](http://msdn.microsoft.com/en-us/library/aa225896(SQL.80).aspx).
// Create our reporting services class
ReportingService theRS = new ReportingService();
theRS.Credentials = System.Net.CredentialCache.DefaultCredentials;
// We need to setup a data source reference to an existing shared data source
DataSourceReference theDSRef = new DataSourceReference();
theDSRef.Reference = "/Path/To/ExistingSharedDataSource";
DataSource[] theDSArray = new DataSource[1];
DataSource theDS = new DataSource();
theDS.Item = (DataSourceReference)theDSRef;
theDS.Name = "NameOfSharedDataSource";
theDSArray[0] = theDS;
try
{
// Attempt to change the data source of the report
theRS.SetReportDataSources("/Path/To/ReportName", theDSArray);
Console.Out.WriteLine("We have changed the data source");
}
catch (System.Web.Services.Protocols.SoapException e)
{
Console.Out.WriteLine(e.Message);
Console.Out.WriteLine(e.Detail.InnerXml.ToString());
}
In this example, the ReportingService class is taken from the Proxy class that I generated to talk to the web service, which is described [here](http://msdn.microsoft.com/en-us/library/aa256607(SQL.80).aspx).
I hope this helps some. Let me know if you're looking for something different.

Related

Dotmim.Sync is throwing exception when synchronizing existing SQLite with SQL Server databases

I get a Dotmim.Sync.SyncException when calling the agent.SynchronizeAsync(tables) function:
Exception: Seems you are trying another Setup tables that what is stored in your server scope database. Please make a migration or create a new scope
This is my code:
public static async Task SynchronizeAsync()
{
var serverProvider = new SqlSyncProvider(serverConnectionString);
// Second provider is using plain old Sql Server provider, relying on triggers and tracking tables to create the sync environment
var clientProvider = new SqliteSyncProvider(Path.Combine(FileSystem.AppDataDirectory, "treesDB.db3"));
// Tables involved in the sync process:
var tables = new string[] { "Trees" };
// Creating an agent that will handle all the process
var agent = new SyncAgent(clientProvider, serverProvider);
// Launch the sync process
var s1 = await agent.SynchronizeAsync(tables);
await agent.LocalOrchestrator.UpdateUntrackedRowsAsync();
var s2 = await agent.SynchronizeAsync();
}
I'm the author of Dotmim.Sync
Do not hesitate to to fill an issue on Github if you are still struggling.
Regarding your issue, I think you have made some tests with different tables.
You need to stick with a set of tables, because DMS needs to create different things (triggers / stored proc and so on)
If you want to test different setups, you need to define differents scopes.
You have a complete documentation on https://dotmimsync.readthedocs.io/

How would I configure Effort Testing Tool to mock Entity Framework's DbContext withOut the actual SQL Server Database up and running?

Our team's application development involves using Effort Testing Tool to mock our Entity Framework's DbContext. However, it seems that Effort Testing Tool needs to be see the actual SQL Server Database that the application uses in order to mock our Entity Framework's DbContext which seems to going against proper Unit Testing principles.
The reason being that in order to unit test our application code by mocking anything related to Database connectivity ( for example Entity Framework's DbContext), we should Never need a Database to be up and running.
How would I configure Effort Testing Tool to mock Entity Framework's DbContext withOut the actual SQL Server Database up and running?
*
Update:
#gert-arnold We are using Entity Framework Model First approach to implement the back-end model and database.
The following excerpt is from the test code:
connection = Effort.EntityConnectionFactory.CreateTransient("name=NorthwindModel");
jsAudtMppngPrvdr = new BlahBlahAuditMappingProvider();
fctry = new BlahBlahDataContext(jsAudtMppngPrvdr, connection, false);
qryCtxt = new BlahBlahDataContext(connection, false);
audtCtxt = new BlahBlahAuditContext(connection, false);
mockedReptryCtxt = new BlahBlahDataContext(connection, false);
_repository = fctry.CreateRepository<Account>(mockedReptryCtxt, null);
_repositoryAccountRoleMaps = fctry.CreateRepository<AccountRoleMap>(null, _repository);
The "name=NorthwindModel" pertains to our edmx file which contains information about our Database tables
and their corresponding relationships.
If I remove the "name=NorthwindModel" by making the connection like the following line of code, I get an error stating that it expects an argument:
connection = Effort.EntityConnectionFactory.CreateTransient(); // throws error
Could you please explain how the aforementioned code should be rewritten?
You only need that connection string because Effort needs to know where the EDMX file is.
The EDMX file contains all information required for creating an inmemory store with an identical schema you have in your database. You have to specify a connection string only because I thought it would be convenient if the user didn't have to mess with EDMX paths.
If you check the implementation of the CreateTransient method you will see that it merely uses the connection string to get the metadata part of it.
public static EntityConnection CreateTransient(string entityConnectionString, IDataLoader dataLoader)
{
var metadata = GetEffortCompatibleMetadataWorkspace(ref entityConnectionString);
var connection = DbConnectionFactory.CreateTransient(dataLoader);
return CreateEntityConnection(metadata, connection);
}
private static MetadataWorkspace GetEffortCompatibleMetadataWorkspace(ref string entityConnectionString)
{
entityConnectionString = GetFullEntityConnectionString(entityConnectionString);
var connectionStringBuilder = new EntityConnectionStringBuilder(entityConnectionString);
return MetadataWorkspaceStore.GetMetadataWorkspace(
connectionStringBuilder.Metadata,
metadata => MetadataWorkspaceHelper.Rewrite(
metadata,
EffortProviderConfiguration.ProviderInvariantName,
EffortProviderManifestTokens.Version1));
}

Database connection from Java handler BIRT

I'm creating a rptlibrary to share with all the reports in my company.
The library has an oda datasource created and shared to all reports. We want to do some querys from ReportEventAdapter.initialize() to the database to get information from the database. I can acces the datasource in the library in this way:
ReportDesignHandle rdh = (ReportDesignHandle)reportContext.getReportRunnable().getDesignHandle();
DesignSessionImpl ds = rdh.getModule().getSession();
String rsf = ds.getResourceFolder( );
LibraryHandle libhan = ds.openLibrary(rsf + "/my.rptlibrary" ).handle( );
DataSourceHandle datasource = libhan.findDataSource("myDS");
But once I have the datasource, there's no way to get a connection to the database from the datasource. The only way to do this, is creating a classic JDBC connection to the database using the data from the datasource? Is there any way to use a more elegant method to connect to the database from the java handler? Like using pooling, reusing the connection, etc..
Thanks.
We can iterate over dataset values in a report script event, thus if a dataset is defined with a JNDI URL, queries can take advantage of a connection pool.
However it is quite complicated. There is a full example in this topic: the script defined in "getDefaultValueList" event of the report parameter can be moved anywhere in the report and then initialize a global variable. In particular we could move it to "initialize" event, or to "beforeFactory" event (in your case "beforeFactory" is probably what you want).

Insert data into external MSSQL database through Yii Framework

I'm using Yii Framework to create my project. I need to export some data from MySQL (my project) to an external Microsoft SQL server which is on the same network.
Basically, the user needs to click on a button (which will do the export-insert) in my view and the results should be displayed - Success (if the query has been successful) or Failure (if something went wrong).
The results part is quite easy as I'll be using 'setFlash' to display the appropriate message but I want to know how to insert data into an external database through Yii.
Do you have any idea how this can be done?
Well, I agree with #SuVeRa on the first part of defining two db instances in the config.php but i don't think the sql Commands part is necessary (Plus i hate writing sql :D )
Instead you can do:
class SomeModel extends CActiveRecord
{
...
// Override the getDbConnection() function to use the ms sql db connection
public function getDbConnection()
{
return Yii::app()->ms_sql_db_connection; // The name of the connection in config.php
}
public function transfer()
{
// Here you can do all the transferring logic using normal Yii Active Record functions
}
}
Check out the docs on getDbConnection().

Fluent NHibernate ExportSchema without connection string

I want to generate a database script without having an actual database connection string declared.
To do this for now i use NHibernate ExportSchema bases on a NHibernate configuration generated with Fluent NHibernate this way (during my ISessionFactory creation method):
FluentConfiguration configuration = Fluently.Configure();
//Mapping conf ...
configuration.Database(fluentDatabaseProvider);
this.nhibernateConfiguration = configuration.BuildConfiguration();
returnSF = configuration.BuildSessionFactory();
//Later
new SchemaExport(this.nhibernateConfiguration)
.SetOutputFile(filePath)
.Execute(false, false, false);
fluentDatabaseProvider is a FluentNHibernate IPersistenceConfigurer which is needed to get proper sql dialect for database creation.
When factory is created with an existing database, everything works fine.
But what i want to do is to create an NHibernate Configuration object on a selected database engine without a real database behind the scene... And i don't manage to do this.
If anybody has some idea.
This is what I used. My mistake was calling BuildSessionFactory which tries to connect to the database:
var config = Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2008)
.Mappings(m =>
m.FluentMappings.AddFromAssemblyOf<SessionManager>());
new SchemaExport(config.BuildConfiguration())
.SetOutputFile(filedestination)
.Create(false, false);
Try using:
.Create(false, false);
inplace of
.Execute(false, false, false);
Do not add the connectionstring property to the IPersistenceConfigurer (fluentDatabaseProvider).

Resources