April 6, 2011 at 8:47 am
I am trying to write a little C# class that deploys my reports and/or datasources using Reporting Services web service.
Everything looks almost fine... I can deploy datasources, create folders and deploy my report to these folders, BUT...
...During report deployment, I always get a warning that it cannot find the datasource it needs, even if I have deployed it with the same name and in the appropriate folder (Data Sources in my case).
If I deploy my shared satasource through BIDS, then I can deploy my reports through C# without problem.
Looking through the RDS file, I can see that a shared datasource has a DataSourceID (a GUID) that is probably what the report is looking for at deployment time.
Unfortunately, in the DataSourceDefinition class, I can't see any way to specify that DataSourceID.
My code looks like this
ReportingService2005 rs = new ReportingService2005();
rs.Url = MyWebRefUrl;
DataSourceDefinition definition = new DataSourceDefinition();
definition.CredentialRetrieval = CredentialRetrievalEnum.Integrated;
definition.ConnectString = @"data source=MyLaptop;initial catalog=AdventureWorks";
definition.Enabled = true;
definition.EnabledSpecified = true;
definition.Extension = "SQL";
definition.ImpersonateUserSpecified = false;
//Use the default prompt string.
definition.Prompt = null;
definition.WindowsCredentials = false;
try
{
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
rs.CreateDataSource("MyTestDataSource", "/Data Sources", false, definition, null);
MessageBox.Show("Done");
}
catch (SoapException ex)
{
MessageBox.Show(String.Format("{0} ({1})", ex.Message, ex.Source), "Soap Exception");
}
catch(Exception ex)
{
MessageBox.Show(String.Format("{0} ({1})", ex.Message, ex.Source), "Error");
}
Any idea what I am missing?
😀
April 11, 2011 at 6:28 pm
You're not doing anything wrong. And I know it has a GUID in there, but that's not what it is actually using. It's actually just using the DataSources/DataSources/DataSourceReference.
If you look closely, you'll see it doesn't have a fully qualified name; only the project does. I suspect that BIDS swallows the warning and then uses rs.SetItemDataSources to fix the data source according to the project settings; and I do the same thing in my scripts. (I just iterate the warnings array that gets returned and ignore anything with the string rsDataSourceReferenceNotPublished in it).
What you can do to prove this is to modify the RDL to have a fully qualified DataSourceReference element before you publish it with your script. It will work without the warning. But I prefer not to modify the RDL I'm uploading.
April 12, 2011 at 3:27 am
Many thanks,
I'll have a go at this
May 5, 2011 at 11:04 am
Took me a while to get back to this... and it's working fine!
Thanks
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply