Skip to content

Blank crystal report using typed dataset visual c# 2008

eddy nhara

Asked Dec 7, 2010, 12:15 AM EST1 answer
Share
LinkedInX
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.

Java
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,

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 1 short reply