Binding a dataset to crystal report at run time - ms access

Posted on 2006-05-08
Last Modified: 2012-06-27
EE Team,

I have code where in i define the sql with where condition based on certain user selection criteria.


ReportDS = Select * from employee where emp_id = combobox1.selectedvalue and emp_name ='abc'

The sql works fine. I create a dataset of the result set return from this query.

My table has 100 records, based on this query i should get 10 records.

Now. i use something lise this

        Dim DocReport As New DoctorReport
        Me.CrystalReportViewer1.ReportSource = DocReport

The crystal report viewer displays all 100 records.

While create the crystal report thru wizard.

I select  

 oble db , jet engine 4 ..

 then i point it to my mdb file, then i add my required table.

 then i select only particular fields which i require.

 no other selection.

 i just want to show report based on my dataset. but what is actually happening is its not considering my dataset and i just displaying all records.

plzz help me in my logic or the way it should be done..

Question by:Apu_Shah
    LVL 69

    Accepted Solution

    Hi Apu_Shah,

    see "Reporting Off ADO.NET Datasets" from

    LVL 2

    Author Comment

    The only difference between the example shown and what i have done is.

    I am creating dataset during runtime based on my sql.

    and the Example shown, create a seperate dataset1 in the project as well as in the code.

    I dont know why do we need to do it two times.

    Plz, explain me the concept.

    Thanks for your reply.

    LVL 69

    Expert Comment

    by:Éric Moreau
    but when you designed your report, have you bound it to the database or on a XML schema?
    LVL 2

    Author Comment

    when i defined the report i did bound to database.

    I did, ADODB connection where it asked me for the mdb file. i mentioned that, then i have also mentioned the table and the required fields.

    plz help me in this, its a high priority for me.

    LVL 69

    Expert Comment

    by:Éric Moreau
    >>when i defined the report i did bound to database.

    That's the problem. You need to bind it to XML schema.

    LVL 2

    Author Comment

    i am sure , why its not working for me

    i used write xml command , also i have a xsd defined. this xsd has one table.

    but when i use the field explorer and, more data source .. and add xsd., the xsd doesnt show any fields that i can use to select.

    plz let me know some easy steps to do this.

    I am new to CR. so plz help me

    LVL 2

    Author Comment


    I got it worked, i used report . RecordSelectionFormula

    this works like a charm. not xsd not xml..

    works great.

    Thanks for your help....

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
    Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now