Click here to Skip to main content
15,895,779 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;




public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        ReportDocument rpt = new ReportDocument();
        bday ds = new bday();
       DataTable dt = new DataTable();
       dt.TableName = "crystal report";
       dt = getallorders();
       ds.Tables[0].Merge(dt);
       rpt.Load(Server.MapPath("~/ROKKIE.rpt"));
      rpt.SetDataSource(ds);
     CrystalReportViewer1.ReportSource = rpt;
    }

    public DataTable getallorders()
    {
        SqlConnection con = new SqlConnection();
        con.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["KKConnectionString"].ConnectionString;
        SqlCommand cmd = new SqlCommand();
        DataSet ds = null;
        SqlDataAdapter adapter;
        try
        {
            con.Open();
            cmd.CommandText = "select * from jj";
      
            
            cmd.Connection = con;
            ds = new DataSet();
            adapter = new SqlDataAdapter(cmd);
            adapter.Fill(ds, "user");


        }

        catch (Exception ex)
        {
            throw new Exception(ex.Message);
        }

        finally
        {
            cmd.Dispose();
            con.Close();
        }

        return ds.Tables[0];

    }
}


I am trying this code to bring data from databse to over crystal report data is not coming over it from databse only blank report is coming with database table coloum name.

like

FIRSTNAME SECONDNAME
Posted
Updated 7-Jan-15 22:18pm
v2
Comments
KaushalJB 8-Jan-15 5:04am    
In this line : dt = getallorders(); ..... debug and tell is your dt filled or null ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900