After compiling the application, the report in reportViewer does not work if there is no XML file next to the .exe file, in which the server, the login and the password are specified when compiling.

Report startup code :

private void dateTimePicker1_ValueChanged(object sender, EventArgs e) { this.DataTable4TableAdapter.Fill(this.DandDDataSet.DataTable4, dateTimePicker1.Value.Date.ToString()); this.reportViewer1.RefreshReport(); } 

I do not want this file to reach the end users of the program.
Is it possible to specify the connection string inside? If yes, please give me an example.

Earlier, I did a report like this:

 DandDDataSet m = new DandDDataSet(); cn.Open(); SqlDataAdapter da = new SqlDataAdapter("запрос", cn); da.Fill(m, m.Tables[0].TableName); ReportDataSource rds = new ReportDataSource("DataSet1", m.Tables[0]); this.reportViewer1.LocalReport.DataSources.Clear(); this.reportViewer1.LocalReport.DataSources.Add(rds); this.reportViewer1.LocalReport.Refresh(); this.reportViewer1.RefreshReport(); 

But it seems to me that this is a crutch.

  • The xml file is a report file, where the connection to the database is described, and that is why there is a login / password? - kvvk
  • @kvvk, this file is automatically generated when the program is compiled. I solved the problem in the second way that I described. - Winteriscoming

0