This is a migrated thread and some comments may be shown as answers.

programatically pass the connection string to the ssrs reports

1 Answer 107 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
vinayak.v
Top achievements
Rank 1
vinayak.v asked on 20 Oct 2010, 09:08 AM
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....

1 Answer, 1 is accepted

Sort by
0
Massimiliano Bassili
Top achievements
Rank 1
answered on 20 Oct 2010, 09:19 AM
Vinayak, not sure why you keep posting questions about SSRS in this forum which is for Telerik Reporting product and not Reporting services. My advice would be going to the SSRS forums and post your inquiries there, here they are irrelevant and might be considered spam.

Cheers!
Tags
General Discussions
Asked by
vinayak.v
Top achievements
Rank 1
Answers by
Massimiliano Bassili
Top achievements
Rank 1
Share this question
or