eddy nhara

eddy nhara

  • NA
  • 2
  • 8.7k

Blank crystal report using typed dataset visual c# 2008

Dec 7 2010 5:15 AM
I am fairly new to c# and am having trouble displaying my selected database data which will have been loaded into a datatable of a typed dataset in a crystal report. The report comes out blank each time even after selecting the option in crystal reports to display the selected datatable column.Can someone please assist. The code i hve used is below, maybe there is something wrong with the code but i just cant crack it.

private void getReportDataSelection()
        {
          
            DataSet Ds = new DataSet();
            
            
if (radiobutton1.Checked  )
            {
                
ArrayList aList = new ArrayList();
                
string cString = "Data Source=Server\\SQLEXPRESS;InitialCatalog=MyDb;Integrated Security=True";
               
 SqlConnection myConnection = new SqlConnection(cString);
                
CrystalReport9  report = new CrystalReport9 ();
                               
                myConnection.Open();
                
String Query1 = ("SELECT sum(column1)FROM Table1");
                
SqlDataAdapter ad = new SqlDataAdapter(Query1, myConnection);
 
 //my_dt is the name of the datatable in the typed dataset              

ad.Fill(Ds  , "my_dt");
                if (Ds.Tables[0].Rows.Count != 0)
                {
                
  report.SetDataSource(Ds.Tables[0]);
                    
rptViewer.crystalReportViewer1.ReportSource = report;
                }
                                 
                         
                myConnection.Close();
 


            }
Thanks in advance,

Answers (1)