i successfully designed and filled my Crystal report via code not via wizard.

i added Crystal report via addNEWITEM
i added dataset in aap_code via addNEWITEM
i added datatable into dataset via addNEWITEM
Via code i made report and filled dataset and table with data
Run and display. Successfully done.
but my question is that how to do it fully via code like for steps 1,2,3 ? I don't want to add it via AddNewItem etc, isn't there any way to add these via code ? i did, i created some datasets and table via code like we do for Gridview etc but that doesn't appear in DATA connections of crystal report etc.

String conStr =WebConfigurationManager.ConnectionStrings["LoginDatabaseConnectionString"].ConnectionString;

protected void Page_Load(object sender, EventArgs e)
    if (!IsPostBack) 

protected void Dataset_load() 
    SqlConnection sqlcon = new SqlConnection(conStr);
    SqlCommand sqlCom = new SqlCommand("select * from Login", sqlcon);
    SqlDataAdapter sqlDA = new SqlDataAdapter(sqlCom);
   // DataSet ds = new DataSet("CRDataSet");


        DataSet1 ds = new DataSet1();
        DataTable dt = new DataTable("DT_CR");

        ReportDocument rd = new ReportDocument();
        CrystalReportViewer1.ReportSource = rd;

    catch (Exception exc)

done, i added code ia designer and figured out important elements to add

This Code is helpfull for me.
thanx for nice sharing.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.