question

KwebenaAcquah-9104 avatar image
0 Votes"
KwebenaAcquah-9104 asked KwebenaAcquah-9104 edited

how to load data from sql database onto an rdlc report with a DataSet Already

i am having a usercontrol that loads my rdlc report in c# like this;

  DataTable dt = new DataTable();
             dt.Columns.Add(new DataColumn("Subject1", typeof(int)));
             dt.Columns.Add(new DataColumn("Subject2", typeof(int)));
             dt.Columns.Add(new DataColumn("Subject3", typeof(int)));
             dt.Columns.Add(new DataColumn("Subject4", typeof(int)));
             DataRow dr = dt.NewRow();
             dr["Subject1"] = 23;
             dr["Subject2"] = 32;
             dr["Subject3"] = 33;
             dr["Subject4"] = 874;
             dt.Rows.Add(dr);
             ReportDataSource reportDataSource = new ReportDataSource();
             reportDataSource.Name = "DataSet1";
             reportDataSource.Value = dt;
             reportViewer.LocalReport.ReportPath = "C:\\Users\\hp\\source\\repos\\SMSKICSO\\SMSKICSO\\myReports\\TermlyReport.rdlc";
             reportViewer.LocalReport.DataSources.Add(reportDataSource);
             reportViewer.RefreshReport();



Problem: can i be able to doe this;
dr["Subject1"] = to a particular column in datagridview in wpf in c#;
such that when ever a particular row is selected that particular column row will be maped to my rdlc dataset1 report;
please can some one help resolve the issue thank you in advance;


Please: the sqlDatabase Data i have is thesame as the DataSet1;

dotnet-csharpdotnet-wpf-xaml
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

PeterFleischer-3316 avatar image
0 Votes"
PeterFleischer-3316 answered KwebenaAcquah-9104 edited

Hi,
you can try following code:

          DataTable dt = new DataTable("DataSet1");
          string cnString = @"Data Source=SQLServer;Initial Catalog=Demo;Integrated Security=True";
          string sqlCmd = "SELECT Subject1, Subject2, Subject3, Subject4 FROM Tab1";
          using (da sqlDataAdap = new SqlDataAdapter(sqlCmd, cnString)) da.Fill(dt);
          ReportDataSource reportDataSource = new ReportDataSource() {Name = "DataSet1", Value = dt};
          reportViewer.LocalReport.ReportPath = "C:\\Users\\hp\\source\\repos\\SMSKICSO\\SMSKICSO\\myReports\\TermlyReport.rdlc";
          reportViewer.LocalReport.DataSources.Add(reportDataSource);
          reportViewer.RefreshReport();
· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

thanks very much sir!

0 Votes 0 ·

can you help fix this problem am having here please via this link

https://docs.microsoft.com/en-us/answers/questions/354528/how-to-stop-replication-of-row-in-rdlc-report.html
thank you very much sir

actually want to get any selected to show according to the report design format please sir help me out please

0 Votes 0 ·

please sir can you help me solve this problem.
how can i do this;
dr["Subject1"] = a particular datagrid column;
please sir is this possible if yes please do write a code for me please thanks

0 Votes 0 ·

please help !!!!!!!!!!!!!!!!!!!!!! me on the comment i have posted just of recent please sir

0 Votes 0 ·