Note that there are some explanatory texts on larger screens.

plurals
  1. POCrystalReport and Stored Procedures using C# Question
    primarykey
    data
    text
    <p>I have an application which needs to generate a report. However, I do not know how to generate a report using CrystalReport which is based on a query. Let's say I just need to generate report from my database which shows the values returned by my select query. I've never used Crystal Reports before so I'm new to this. </p> <p>Thanks everyone :)</p> <p>EDIT:</p> <p>So far, this is what I have:</p> <pre><code>ConnectionString myConnString = new ConnectionString(); string connString = myConnString.getConnectionString(); SqlConnection connSearch = new SqlConnection(connString); connSearch.Open(); SqlCommand cmdLoad = new SqlCommand("Search", connSearch); cmdLoad.CommandType = CommandType.StoredProcedure; cmdLoad.Parameters.Add(new SqlParameter("@AccountID", currentUser)); cmdLoad.Parameters.Add(new SqlParameter("@PeriodID", " ")); cmdLoad.Parameters.Add(new SqlParameter("@PriceID", " ")); cmdLoad.Parameters.Add(new SqlParameter("@ExpenseID", " ")); cmdLoad.Parameters.Add(new SqlParameter("@InventoryID", " ")); cmdLoad.Parameters.Add(new SqlParameter("@ProductInID", " ")); cmdLoad.Parameters.Add(new SqlParameter("@ProductOutID", " ")); cmdLoad.Parameters.Add(new SqlParameter("@PeriodMonth", periodMonth.Trim().ToUpper())); cmdLoad.Parameters.Add(new SqlParameter("@PeriodYear", periodYear)); SqlDataReader read = cmdLoad.ExecuteReader(); DataSet ds = new DataSet(); DataTable dt = new DataTable("Results"); ds.Tables.Add(dt); ds.Load(read, LoadOption.PreserveChanges, ds.Tables[0]); CrystalReport1 crystal = new CrystalReport1(); crystal.SetDataSource(ds); crystalReportViewer1.ReportSource = crystal; connSearch.Close(); connSearch.Dispose(); </code></pre> <p>However, there seems to be something wrong here since it always produce an exception saying that the report has no tables pointing to the <code>crystal.SetDataSource(ds);</code> line.</p> <p>Anybody help me please? :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload