programatically pass the connection string to the ssrs reports
hi... to all i've created ssrs reports local following is my code.. public void source(string tbname,string Rptname) { ReportViewer1.Visible = true; string myQuery = "select * from " + tbname; SqlConnection myConnection = new SqlConnection(ConnectionString); SqlCommand myCommand = new SqlCommand(myQuery, myConnection); myCommand.Connection.Open(); SqlDataAdapter da = new SqlDataAdapter(myCommand); DataSet dt = new DataSet(); da.Fill(dt); //ReportParameter[] p = new ReportParameter[1]; //p[1] = new ReportParameter("@p_dno", "5"); //this.ReportViewer1.LocalReport.SetParameters(p); //DataSet dt = new DataSet(); //dt = p; ReportViewer1.LocalReport.ReportPath = Rptname + ".rdlc" ; ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local; ReportDataSource datasource = new ReportDataSource("employeeDataSet_" + tbname , dt.Tables[0]); ReportViewer1.LocalReport.DataSources.Clear(); ReportViewer1.LocalReport.DataSources.Add(datasource); } now it works good.. as i expected... but i want to pass the datasource connection string from here is there any way to pass the datasource programatically....
October 20th, 2010 11:10am

="data source=" & Parameters!ServerName.Value & ";initial catalog=AdventureWorks http://msdn.microsoft.com/en-us/library/ms156450.aspxBest Regards, Uri Dimant SQL Server MVP http://dimantdatabasesolutions.blogspot.com/ http://sqlblog.com/blogs/uri_dimant/
Free Windows Admin Tool Kit Click here and download it now
October 20th, 2010 11:29am

Hi vinayak.v, For a local report(.rdlc), the data source is a custom dataset(or data table), which is passed from the behind code. In other words, for a local report, there is no datasource definition in the report. So, we don't need to pass the connection string to the report. If there is anything unclear, please feel free to ask. Thanks, Jin ChenJin Chen - MSFT
October 21st, 2010 12:32pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics