المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : crystal report data not showing



C# Programming
06-14-2009, 08:40 AM
hi all

i am using vs.net 2005 c# window application to learn to make a crystal report which connect to a ms sql database programically

hence i tryed this code:

my_rp objRpt;
// Creating object of our report.
objRpt = new my_rp();

String ConnStr = "Data Source=com-DEV;Initial Catalog=DB;Persist Security Info=True;User ID=abc;Password=abc";

SqlConnection myConnection = new SqlConnection(ConnStr);

String Query1 = "SELECT [index], [Model name] FROM Valve";

SqlDataAdapter adapter = new SqlDataAdapter(Query1, ConnStr);

DataSet Ds = new DataSet();

// here my_dt is the name of the DataTable which we
// created in the designer view.
adapter.Fill(Ds, "dt_my_project_table");

if (Ds.Tables[0].Rows.Count == 0)
{
MessageBox.Show("No data Found", "CrystalReportWithOracle");
return;
}

// Setting data source of our report object
objRpt.SetDataSource(Ds);

CrystalDecisions.CrystalReports.Engine.TextObject root;
root = (CrystalDecisions.CrystalReports.Engine.TextObject)
objRpt.ReportDefinition.ReportObjects["TEST1"];
root.Text = "Sample Report By Using Data Table!!";
//txt_header
// Binding the crystalReportViewer with our report object.
crystalReportViewer1.ReportSource = objRpt;

how ever the data doesnt show out, i created some break in the code and reliase that the Ds.Tables[0].Rows.Count have the data found in it meaning it works fine how ever the data just dont show out in the crystal report only the header does.

anyone know whats the problem please advice me please