0

before going to problem let me clear that i know there are similar questions ask before but could not find the answer of my problem. my problem is:
I want to select the Data Source at runtime. First of all, i simply create a report by making a shared data source. then i create a data set using this data source. I run the report and it is working perfectly. Then I create two parameters, one for data source and one for data set. both parameters are type of "Text", their parameter visibility is "Visible" and their Available and Default values are "None". Then I created a second data source which is embedded and its connection string is :
="Data Source=" & Parameters!DataSource.Value & ";Initial Catalog=" & Parameters!DataSet.Value
Now when I click on test connection button it shows me error :
"The ConnectionString property has not been initialized."
Now can any one please explain me how to handle it. my credentials are correct. I test credentials by making embedded data source and hard codded connection string its working fine but not with dynamic connection string.

Hamza
  • 49
  • 3
  • 7
  • Have you tried to display the ConnectionString in a textbox to ensure it is ok? – Sébastien Sevrin Jun 15 '15 at 14:12
  • @SébastienSevrin Sorry, I cant under stand your question. I mean how to do this? actually i'm new in reporting and i don't know much. I just read some article on dynamic data source and perform steps – Hamza Jun 15 '15 at 14:16
  • Ijust wanted to know if you tried adding a textbox to your report, with the ConnectionString expression (`="Data Source=" & Parameters!DataSource.Value & ";Initial Catalog=" & Parameters!DataSet.Value`), to be sure your ConnectionString is what you expect it to be. – Sébastien Sevrin Jun 15 '15 at 14:36
  • after reading your comment i insert a textbox in my report a write my connection string in its expression. when i run it displayed the connection string but in place of both parameters values it is showing the parameter that i have entered for data source. i mean i have entered "DataSource1" and "DataSet1" as parameters name but results are like : **Data Source = DataSource1; Initial Catalog = DataSource1**. I have run this report using shared data source. – Hamza Jun 15 '15 at 15:50
  • If it displays your expected connection string, yes it's giving correct results. If it works with a static connection string and your expression is returning the same connection string, it should work. Are you sure there isn't something else? Where are your credentials set, in the ConnectionString or in the Credentials tab? – Sébastien Sevrin Jun 15 '15 at 15:51
  • @SébastienSevrin Sorry I have edited my previous comment please read it. ignore it if you already have read it. it is not displaying expected result. i have mentioned it in my previous edited comment. second thing my credentials are set in Credential Tab. i'm using user name and password option – Hamza Jun 15 '15 at 16:01
  • Ok then obviously the problem comes from your `DataSet` parameter, you need to ensure the expression is ok (ex: `="Data Source=" & Parameters!DataSource.Value & ";Initial Catalog=" & Parameters!DataSource.Value` instead of `="Data Source=" & Parameters!DataSource.Value & ";Initial Catalog=" & Parameters!DataSet.Value`) – Sébastien Sevrin Jun 15 '15 at 16:06
  • yes i have write your connection string and now its giving me correct result but problem is still there. its is giving me same error as i described in question even if i changed my connection string in data source – Hamza Jun 15 '15 at 16:16

1 Answers1

0

You can't use a Shared Data Source with a dynamic data source. Use an embedded one. I think it's to prevent you from corrupting other reports' data sources.

http://www.keepitsimpleandfast.com/2012/08/how-to-use-dynamic-data-sources-in-your.html

Hannover Fist
  • 10,393
  • 1
  • 18
  • 39
  • ok i have changed my 1st datasource to embedded but i'm still facing same problem – Hamza Jun 16 '15 at 11:17
  • if i ignore the error and select my Dynamic datasource for report and run the report then report gives me error : **Cannot creat a connection to data source 'DataSource1'** – Hamza Jun 16 '15 at 12:36
  • Did you test it with your real values hard coded to make sure the connection works first? Are there any non-alphanumeric characters in your server or database names? Your server name isn't **DataSource1**, right? Do you have default values for your server and DBs? – Hannover Fist Jun 16 '15 at 15:14
  • yes i hard coded it and its working fine. there is a dash(-) in my server name. and DataSource1 is the name of my Dynamic data source. By default values, if you mean default values for parameters then No. i don't set default values. – Hamza Jun 16 '15 at 15:28
  • Try setting your server and database names for the default values for your server and database parameters. I think it's supposed to work without defaults but maybe not for some reason. – Hannover Fist Jun 16 '15 at 15:44
  • I think I could't tell my real problem clearly or you misunderstand. My actual problem is that when i tried to create dynamic data source, i just got the error. first i create an embedded data source with hard codded connection string and create a data set using this data source and run the report, every thing is fine but when i changed the connection string of this data source to dynamic or tried to create another dynamic embedded data source, i got error which i mentioned earlier.so if data source cant be created/updated then i cant use this data source to create a dataset.that's my problem. – Hamza Jun 16 '15 at 16:03
  • my procedure might be wrong but this is what I found after searching and the link you past, in that article at the end we have to change hard coded connection string to dynamic and when i do it i just simply got error. – Hamza Jun 16 '15 at 16:09
  • I would think if you hard coded it and it worked, then used those same values as the default values that it would still work. Previously you had **Data Source = DataSource1; Initial Catalog = DataSource1** which looks like you were using the same parameter for your Server **and** Database. Have you check the parameters? – Hannover Fist Jun 16 '15 at 16:47
  • yes i had corrected it. i was just trying to check my connection string by writing it in text box in report and checked the result. results are correct. Now i dont know why its not working. – Hamza Jun 16 '15 at 17:04
  • I don't see why it isn't either. It should just be a matter of using an expression like **="data source=" & Parameters!ServerName.Value & ";initial catalog=" & Parameters!DatabaseName.Value**. I was able to get it working using this formula with and without using a default. Maybe since you have a dash you should use ="Your-Server-Name" in quotes for the default value. – Hannover Fist Jun 16 '15 at 18:07
  • i'm trying to solve it let see what happens. thanks for your time :) – Hamza Jun 17 '15 at 16:40